Trait kipa_lib::socket_server::SocketHandler [−][src]
pub trait SocketHandler { type SocketType: Read + Write + Send + Sync + 'static; fn set_socket_timeout(
&self,
socket: &mut Self::SocketType,
timeout: Option<Duration>
) -> Result<()>; fn get_socket_peer_address(
&self,
socket: &Self::SocketType
) -> Option<Address>; fn send_data(
&self,
data: &[u8],
socket: &mut Self::SocketType,
deadline: Option<Instant>
) -> Result<()> { ... } fn receive_data(
&self,
socket: &mut Self::SocketType,
deadline: Option<Instant>
) -> Result<Vec<u8>> { ... } }
Type for structs that interface with sockets
Associated Types
type SocketType: Read + Write + Send + Sync + 'static
The type of the socket to use for sending/receiveing data
Required Methods
fn set_socket_timeout(
&self,
socket: &mut Self::SocketType,
timeout: Option<Duration>
) -> Result<()>
&self,
socket: &mut Self::SocketType,
timeout: Option<Duration>
) -> Result<()>
Set the timeout of a SocketType
fn get_socket_peer_address(&self, socket: &Self::SocketType) -> Option<Address>
Get the address of the peer connected to the other side of the socket
Provided Methods
fn send_data(
&self,
data: &[u8],
socket: &mut Self::SocketType,
deadline: Option<Instant>
) -> Result<()>
&self,
data: &[u8],
socket: &mut Self::SocketType,
deadline: Option<Instant>
) -> Result<()>
Send data down a socket. Handles writing the length of the data
fn receive_data(
&self,
socket: &mut Self::SocketType,
deadline: Option<Instant>
) -> Result<Vec<u8>>
&self,
socket: &mut Self::SocketType,
deadline: Option<Instant>
) -> Result<Vec<u8>>
Receive data from a socket. Handles reading the length of the data
Implementors
impl SocketHandler for TcpGlobalServer type SocketType = TcpStream;
impl SocketHandler for TcpGlobalClient type SocketType = TcpStream;
impl SocketHandler for UnixSocketLocalServer type SocketType = UnixStream;
impl SocketHandler for UnixSocketLocalClient type SocketType = UnixStream;