pub struct SocketConnection<StateType: Debug> { /* private fields */ }
Expand description
A wrapper for a TcpStream – attaching a custom “state” and unique id to it.
This abstraction plays a role in enabling the “Composite Protocol Stacking” design pattern.
IMPLEMENTATION NOTE: The crate::prelude::Peer object still holds a copy of the state – synced elsewhere with us here
– in the future, this should be reworked.
Implementations§
Source§impl<StateType: Debug> SocketConnection<StateType>
impl<StateType: Debug> SocketConnection<StateType>
pub fn new(connection: TcpStream, initial_state: StateType) -> Self
pub fn connection(&self) -> &TcpStream
pub fn connection_mut(&mut self) -> &mut TcpStream
pub fn id(&self) -> ConnectionId
pub fn state(&self) -> &StateType
pub fn set_state(&mut self, new_state: StateType)
pub fn closed(&self) -> bool
pub fn report_closed(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl<StateType> !Freeze for SocketConnection<StateType>
impl<StateType> RefUnwindSafe for SocketConnection<StateType>where
StateType: RefUnwindSafe,
impl<StateType> Send for SocketConnection<StateType>where
StateType: Send,
impl<StateType> Sync for SocketConnection<StateType>where
StateType: Sync,
impl<StateType> Unpin for SocketConnection<StateType>where
StateType: Unpin,
impl<StateType> UnwindSafe for SocketConnection<StateType>where
StateType: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more