Skip to main content

SocketHandler

Trait SocketHandler 

Source
pub trait SocketHandler {
    // Required methods
    fn socket_read(&mut self, buf: &mut [u8]) -> (usize, SocketResult);
    fn socket_write(&mut self, buf: &[u8]) -> (usize, SocketResult);
    fn socket_write_vectored(
        &mut self,
        _buf: &[IoSlice<'_>],
    ) -> (usize, SocketResult);
    fn socket_ref(&self) -> &TcpStream;
    fn socket_mut(&mut self) -> &mut TcpStream;
    fn protocol(&self) -> TransportProtocol;
    fn read_error(&self);
    fn write_error(&self);

    // Provided methods
    fn socket_wants_write(&self) -> bool { ... }
    fn socket_close(&mut self) { ... }
    fn session_ulid(&self) -> Option<Ulid> { ... }
}

Required Methods§

Source

fn socket_read(&mut self, buf: &mut [u8]) -> (usize, SocketResult)

Source

fn socket_write(&mut self, buf: &[u8]) -> (usize, SocketResult)

Source

fn socket_write_vectored( &mut self, _buf: &[IoSlice<'_>], ) -> (usize, SocketResult)

Source

fn socket_ref(&self) -> &TcpStream

Source

fn socket_mut(&mut self) -> &mut TcpStream

Source

fn protocol(&self) -> TransportProtocol

Source

fn read_error(&self)

Source

fn write_error(&self)

Provided Methods§

Source

fn socket_wants_write(&self) -> bool

Source

fn socket_close(&mut self)

Source

fn session_ulid(&self) -> Option<Ulid>

Returns the owning connection’s session ULID when known. Used by [log_socket_context!] to render the [<session_ulid> - - -] segment of the socket-layer log prefix, matching the format used by the rest of the mux stack. Returns None for contextless implementations (e.g. raw mio::TcpStream); the macro renders - in the ULID slot.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SocketHandler for TcpStream

Source§

fn socket_read(&mut self, buf: &mut [u8]) -> (usize, SocketResult)

Source§

fn socket_write(&mut self, buf: &[u8]) -> (usize, SocketResult)

Source§

fn socket_write_vectored( &mut self, bufs: &[IoSlice<'_>], ) -> (usize, SocketResult)

Source§

fn socket_ref(&self) -> &TcpStream

Source§

fn socket_mut(&mut self) -> &mut TcpStream

Source§

fn protocol(&self) -> TransportProtocol

Source§

fn read_error(&self)

Source§

fn write_error(&self)

Implementors§