// Copyright 2022 The Chromium OS Authors. All rights reserved. // SPDX-License-Identifier: Apache-2.0 //! Unix specific code that keeps rest of the code in the crate platform independent. use std::io::Result; use std::os::unix::net::{UnixListener, UnixStream}; /// Alias to enable platform independent code. pub type SystemListener = UnixListener; /// Alias to enable platform independent code. pub type SystemStream = UnixStream; cfg_if::cfg_if! { if #[cfg(feature = "device")] { use crate::{connection::socket::Endpoint as SocketEndpoint, message::SlaveReq}; use crate::message::MasterReq; pub(crate) type SlaveFsCacheReqSocket = SocketEndpoint; pub(crate) type MasterReqEndpoint = SocketEndpoint; } } /// Collection of platform-specific methods that SystemListener provides. pub(crate) trait SystemListenerExt { /// Accept a connection. fn accept(&self) -> Result; } impl SystemListenerExt for SystemListener { fn accept(&self) -> Result { self.accept().map(|(socket, _address)| socket) } }