pub struct Session { /* private fields */ }Expand description
A QUIC session to a single remote peer.
Cheap to clone — this is just an IrohEndpoint ref-clone plus a u64
handle into the endpoint’s session registry. Sessions are not pooled;
closing one session has no effect on other sessions to the same peer.
Implementations§
Source§impl Session
impl Session
Sourcepub fn from_handle(endpoint: IrohEndpoint, handle: u64) -> Self
pub fn from_handle(endpoint: IrohEndpoint, handle: u64) -> Self
Reconstruct a Session from a handle previously obtained via
Session::connect or Session::accept.
FFI adapters use this to rehydrate a session from a u64 handle that
crossed a language boundary.
Sourcepub fn handle(&self) -> u64
pub fn handle(&self) -> u64
The opaque handle identifying this session inside the endpoint registry.
Sourcepub async fn connect(
endpoint: IrohEndpoint,
remote_node_id: &str,
direct_addrs: Option<&[SocketAddr]>,
) -> Result<Self, CoreError>
pub async fn connect( endpoint: IrohEndpoint, remote_node_id: &str, direct_addrs: Option<&[SocketAddr]>, ) -> Result<Self, CoreError>
Establish a session (QUIC connection) to a remote peer.
Each call creates a dedicated QUIC connection — sessions are not
pooled. Closing one session handle cannot affect other sessions to the
same peer. (Fetch operations continue to use the shared pool for
efficiency; sessions opt out because Session::close closes the
underlying connection.)
Sourcepub async fn accept(endpoint: IrohEndpoint) -> Result<Option<Self>, CoreError>
pub async fn accept(endpoint: IrohEndpoint) -> Result<Option<Self>, CoreError>
Accept an incoming session (QUIC connection) from a remote peer.
Blocks until a peer connects. Returns the new session, or None if
the endpoint is shutting down.
Sourcepub async fn create_bidi_stream(&self) -> Result<FfiDuplexStream, CoreError>
pub async fn create_bidi_stream(&self) -> Result<FfiDuplexStream, CoreError>
Open a new bidirectional stream on this session.
Returns FfiDuplexStream with read_handle / write_handle backed by
body channels — the same interface used by fetch and raw_connect.
Sourcepub async fn next_bidi_stream(
&self,
) -> Result<Option<FfiDuplexStream>, CoreError>
pub async fn next_bidi_stream( &self, ) -> Result<Option<FfiDuplexStream>, CoreError>
Accept the next incoming bidirectional stream from the remote side.
Blocks until the remote opens a stream, or returns None when the
connection is closed.
Sourcepub fn close(&self, close_code: u64, reason: &str) -> Result<(), CoreError>
pub fn close(&self, close_code: u64, reason: &str) -> Result<(), CoreError>
Close this session and remove it from the registry.
close_code is an application-level error code (maps to QUIC VarInt).
reason is a human-readable string sent to the peer.
Sourcepub async fn ready(&self) -> Result<(), CoreError>
pub async fn ready(&self) -> Result<(), CoreError>
Wait for the QUIC handshake to complete on this session.
Resolves immediately if the handshake has already completed.
Sourcepub async fn closed(&self) -> Result<CloseInfo, CoreError>
pub async fn closed(&self) -> Result<CloseInfo, CoreError>
Wait for the session to close and return the close information.
Blocks until the connection is closed by either side. Removes the session from the registry so resources are freed.
Sourcepub async fn create_uni_stream(&self) -> Result<u64, CoreError>
pub async fn create_uni_stream(&self) -> Result<u64, CoreError>
Open a new unidirectional (send-only) stream on this session.
Returns a write handle backed by a body channel.
Sourcepub async fn next_uni_stream(&self) -> Result<Option<u64>, CoreError>
pub async fn next_uni_stream(&self) -> Result<Option<u64>, CoreError>
Accept the next incoming unidirectional (receive-only) stream.
Returns a read handle, or None when the connection is closed.
Sourcepub fn send_datagram(&self, data: &[u8]) -> Result<(), CoreError>
pub fn send_datagram(&self, data: &[u8]) -> Result<(), CoreError>
Send a datagram on this session.
Fails if data.len() exceeds Session::max_datagram_size.
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more