pub struct Session<C: Connection> { /* private fields */ }Expand description
A quic-reverse session over a QUIC connection.
The session provides the main API for:
- Initiating reverse streams to the peer
- Accepting incoming stream requests from the peer
- Managing the session lifecycle
§Example
ⓘ
use quic_reverse::{Session, Config, Role};
// Create a session as the client
let session = Session::new(connection, Role::Client, Config::default());
// Start the session (performs negotiation)
let mut handle = session.start().await?;
// Open a reverse stream
let (send, recv) = handle.open("ssh", Metadata::Empty).await?;Implementations§
Source§impl<C: Connection> Session<C>
impl<C: Connection> Session<C>
Sourcepub fn new(connection: C, role: Role, config: Config) -> Self
pub fn new(connection: C, role: Role, config: Config) -> Self
Creates a new session wrapping the given connection.
The session starts in the Init state. Call start
to begin negotiation.
Sourcepub fn negotiated_params(&self) -> Option<NegotiatedParams>
pub fn negotiated_params(&self) -> Option<NegotiatedParams>
Returns the negotiated parameters, if negotiation has completed.
Sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if the connection was lost.
Sourcepub fn connection(&self) -> &C
pub fn connection(&self) -> &C
Returns a reference to the underlying connection.
Sourcepub async fn start(&self) -> Result<SessionHandle<C>, Error>
pub async fn start(&self) -> Result<SessionHandle<C>, Error>
Starts the session by performing negotiation.
This opens the control stream and performs the Hello/HelloAck
handshake with the peer. On success, the session transitions
to the Ready state.
§Errors
Returns an error if:
- The control stream cannot be opened/accepted
- Negotiation fails (version mismatch, timeout, etc.)
- The session is not in the
Initstate
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for Session<C>
impl<C> RefUnwindSafe for Session<C>where
C: RefUnwindSafe,
impl<C> Send for Session<C>
impl<C> Sync for Session<C>
impl<C> Unpin for Session<C>
impl<C> UnwindSafe for Session<C>where
C: RefUnwindSafe,
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