pub struct ServerSession<S: SyncState> { /* private fields */ }Available on crate feature
server only.Expand description
Per-client session.
Implementations§
Source§impl<S: SyncState> ServerSession<S>
impl<S: SyncState> ServerSession<S>
Sourcepub fn new(
id: ServerSessionId,
client_addr: SocketAddr,
client_public_key: [u8; 32],
initial_state: S,
) -> Self
pub fn new( id: ServerSessionId, client_addr: SocketAddr, client_public_key: [u8; 32], initial_state: S, ) -> Self
Create a new session.
Sourcepub fn id(&self) -> ServerSessionId
pub fn id(&self) -> ServerSessionId
Get the session ID.
Sourcepub fn client_addr(&self) -> SocketAddr
pub fn client_addr(&self) -> SocketAddr
Get the client address.
Sourcepub fn client_public_key(&self) -> &[u8; 32]
pub fn client_public_key(&self) -> &[u8; 32]
Get the client’s public key.
Sourcepub fn state(&self) -> SessionState
pub fn state(&self) -> SessionState
Get the session state.
Sourcepub fn set_state(&mut self, state: SessionState)
pub fn set_state(&mut self, state: SessionState)
Set the session state.
Sourcepub fn server_state(&self) -> &S
pub fn server_state(&self) -> &S
Get the current server state.
Sourcepub fn server_state_mut(&mut self) -> &mut S
pub fn server_state_mut(&mut self) -> &mut S
Get mutable access to the server state.
Sourcepub fn update_server_state(&mut self, state: S)
pub fn update_server_state(&mut self, state: S)
Update the server state and increment version.
Sourcepub fn client_state_version(&self) -> u64
pub fn client_state_version(&self) -> u64
Get the client state version.
Sourcepub fn update_client_state_version(&mut self, version: u64)
pub fn update_client_state_version(&mut self, version: u64)
Update the client state version (from ack).
Sourcepub fn server_state_version(&self) -> u64
pub fn server_state_version(&self) -> u64
Get the server state version.
Sourcepub fn update_client_addr(&mut self, addr: SocketAddr)
pub fn update_client_addr(&mut self, addr: SocketAddr)
Update the client address (for IP roaming).
Sourcepub fn set_extensions(&mut self, extensions: Vec<u16>)
pub fn set_extensions(&mut self, extensions: Vec<u16>)
Set negotiated extensions.
Sourcepub fn extensions(&self) -> &[u16]
pub fn extensions(&self) -> &[u16]
Get negotiated extensions.
Sourcepub fn compression_enabled(&self) -> bool
pub fn compression_enabled(&self) -> bool
Check if compression is enabled.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for ServerSession<S>where
S: Freeze,
impl<S> RefUnwindSafe for ServerSession<S>where
S: RefUnwindSafe,
impl<S> Send for ServerSession<S>
impl<S> Sync for ServerSession<S>
impl<S> Unpin for ServerSession<S>where
S: Unpin,
impl<S> UnwindSafe for ServerSession<S>where
S: 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