pub struct IrohSession<P>where
P: Protocol,{ /* private fields */ }Expand description
A JetStream session over an iroh connection.
Cloning the session is cheap and every clone addresses the same connection, so lanes can be opened from several tasks at once. The connection closes when the last clone goes away.
Implementations§
Source§impl<P> IrohSession<P>where
P: Protocol,
impl<P> IrohSession<P>where
P: Protocol,
Sourcepub fn new(connection: Connection) -> IrohSession<P>
pub fn new(connection: Connection) -> IrohSession<P>
Wrap a connection whose endpoint the caller keeps alive.
The session takes ownership of the connection’s lifetime: when the last handle is dropped the connection closes, even if the caller holds a clone of it.
Sourcepub fn new_owned(connection: Connection, endpoint: Endpoint) -> IrohSession<P>
pub fn new_owned(connection: Connection, endpoint: Endpoint) -> IrohSession<P>
Wrap a connection and keep endpoint alive alongside it.
Sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
The underlying connection.
Sourcepub fn without_datagrams(self) -> IrohSession<P>
pub fn without_datagrams(self) -> IrohSession<P>
Report this session as carrying no datagrams.
r[impl jetstream.session.capabilities]
Session::capabilities derives datagram support from
max_datagram_size, which underneath reads the peer’s
advertised limit and the path MTU. It is silent about this
endpoint’s own configuration: an endpoint built with datagrams
switched off still sees a size, while every send fails and
nothing can arrive. There is no way to read that back from the
connection, so the caller that turned them off says so here.
The override is shared by every handle on this connection, including clones taken before the call: a clone that went on claiming datagrams work would recreate exactly the mismatch this is here to prevent.
Trait Implementations§
Source§impl<P> Clone for IrohSession<P>where
P: Protocol,
impl<P> Clone for IrohSession<P>where
P: Protocol,
Source§fn clone(&self) -> IrohSession<P>
fn clone(&self) -> IrohSession<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P> Datagrams<P> for IrohSession<P>
r[impl jetstream.session.datagrams]
iroh carries QUIC datagrams, which belong to the connection and not
to any stream on it. Only the raw channel is bound here; framing is
the model’s, so both peers agree on it.
impl<P> Datagrams<P> for IrohSession<P>
r[impl jetstream.session.datagrams] iroh carries QUIC datagrams, which belong to the connection and not to any stream on it. Only the raw channel is bound here; framing is the model’s, so both peers agree on it.
Source§fn max_datagram_size(&self) -> Option<u32>
fn max_datagram_size(&self) -> Option<u32>
Source§fn send_datagram_bytes<'life0, 'async_trait>(
&'life0 self,
bytes: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
fn send_datagram_bytes<'life0, 'async_trait>(
&'life0 self,
bytes: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
Source§fn recv_datagram_bytes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Bytes, SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
fn recv_datagram_bytes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Bytes, SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
Source§impl<P> Debug for IrohSession<P>where
P: Protocol,
impl<P> Debug for IrohSession<P>where
P: Protocol,
Source§impl<P> Session<P> for IrohSession<P>
impl<P> Session<P> for IrohSession<P>
Source§fn capabilities(&self) -> Capabilities
fn capabilities(&self) -> Capabilities
r[impl jetstream.session.capabilities]
r[impl jetstream.session.capabilities.degradation]
The conformance row says iroh can carry datagrams. This
connection may not: a peer that never advertised DATAGRAM
support, or a transport configuration with them switched off,
leaves max_datagram_size empty and every send failing. A
capability is what this session has, not what its transport is
capable of in general — reporting the row unconditionally would
let require(Capability::Datagrams) succeed on a session that
cannot carry one.
Source§fn context(&self) -> Context
fn context(&self) -> Context
r[impl jetstream.session.identity] iroh establishes the peer’s public key during the handshake, so the identity is available without the peer asserting anything.
Source§fn open_lane<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<<IrohSession<P> as Session<P>>::ClientLane, SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
fn open_lane<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<<IrohSession<P> as Session<P>>::ClientLane, SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
r[impl jetstream.lane.independence] Every lane is its own QUIC stream, so one lane’s stalled frame does not delay another’s.
Source§fn accept_lane<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<<IrohSession<P> as Session<P>>::ServiceLane, SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
fn accept_lane<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<<IrohSession<P> as Session<P>>::ServiceLane, SessionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
r[impl jetstream.session.symmetric] Either peer may open a lane on an iroh connection, so a client that accepts is not doing anything unusual.
Source§fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
IrohSession<P>: 'async_trait,
r[impl jetstream.session.lifetime] Closing the connection resets every stream opened on it, so lanes terminate with the session rather than outliving it, and calls in flight on them fail rather than hang.
Source§type ClientLane = IrohTransport<P>
type ClientLane = IrohTransport<P>
Source§type ServiceLane = IrohServiceLane<P>
type ServiceLane = IrohServiceLane<P>
Auto Trait Implementations§
impl<P> !RefUnwindSafe for IrohSession<P>
impl<P> !UnwindSafe for IrohSession<P>
impl<P> Freeze for IrohSession<P>
impl<P> Send for IrohSession<P>
impl<P> Sync for IrohSession<P>
impl<P> Unpin for IrohSession<P>
impl<P> UnsafeUnpin for IrohSession<P>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more