Skip to main content

Session

Struct Session 

Source
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

Source

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.

Source

pub fn handle(&self) -> u64

The opaque handle identifying this session inside the endpoint registry.

Source

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.)

Source

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.

Source

pub fn remote_id(&self) -> Result<PublicKey, CoreError>

Return the remote peer’s public key.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn send_datagram(&self, data: &[u8]) -> Result<(), CoreError>

Send a datagram on this session.

Fails if data.len() exceeds Session::max_datagram_size.

Source

pub async fn recv_datagram(&self) -> Result<Option<Vec<u8>>, CoreError>

Receive the next datagram from this session.

Blocks until a datagram arrives, or returns None when the connection closes.

Source

pub fn max_datagram_size(&self) -> Result<Option<usize>, CoreError>

Return the current maximum datagram payload size for this session.

Returns None if datagrams are not supported on the current path.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more