pub struct Session { /* private fields */ }Expand description
A fully managed PO session over any transport.
Handles the handshake, encryption, and frame IO.
Implementations§
Source§impl Session
impl Session
Sourcepub fn state(&self) -> SessionState
pub fn state(&self) -> SessionState
Get the current session state.
Sourcepub fn peer_node_id(&self) -> Option<&NodeId>
pub fn peer_node_id(&self) -> Option<&NodeId>
Get the peer’s node ID (available after handshake).
Sourcepub async fn handshake_initiator(
&mut self,
transport: &mut dyn AsyncFrameTransport,
) -> Result<(), HandshakeError>
pub async fn handshake_initiator( &mut self, transport: &mut dyn AsyncFrameTransport, ) -> Result<(), HandshakeError>
Perform the handshake as the initiator (client).
Sourcepub async fn handshake_responder(
&mut self,
transport: &mut dyn AsyncFrameTransport,
) -> Result<(), HandshakeError>
pub async fn handshake_responder( &mut self, transport: &mut dyn AsyncFrameTransport, ) -> Result<(), HandshakeError>
Perform the handshake as the responder (server).
Sourcepub async fn send(
&mut self,
transport: &mut dyn AsyncFrameTransport,
channel: u32,
data: &[u8],
) -> Result<(), SessionError>
pub async fn send( &mut self, transport: &mut dyn AsyncFrameTransport, channel: u32, data: &[u8], ) -> Result<(), SessionError>
Send encrypted application data.
Sourcepub async fn recv(
&mut self,
transport: &mut dyn AsyncFrameTransport,
) -> Result<Option<(u32, Vec<u8>)>, SessionError>
pub async fn recv( &mut self, transport: &mut dyn AsyncFrameTransport, ) -> Result<Option<(u32, Vec<u8>)>, SessionError>
Receive the next message. Returns (channel_id, decrypted_data).
Automatically handles control frames (Ping/Pong/Close).
Sourcepub async fn close(
&mut self,
transport: &mut dyn AsyncFrameTransport,
) -> Result<(), SessionError>
pub async fn close( &mut self, transport: &mut dyn AsyncFrameTransport, ) -> Result<(), SessionError>
Send a graceful close frame.
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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