Skip to main content

TcpSessionTransport

Struct TcpSessionTransport 

Source
pub struct TcpSessionTransport { /* private fields */ }

Implementations§

Source§

impl TcpSessionTransport

Source

pub fn new(stream: TcpStream) -> Self

Trait Implementations§

Source§

impl SessionTransport for TcpSessionTransport

Source§

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

Send raw bytes to the peer. Read more
Source§

async fn recv_bytes(&self) -> Result<Bytes, CoreError>

Receive the next message from the peer. The returned Bytes is a refcounted view over an opaque buffer; subsequent clone()s are cheap.
Source§

fn set_frame_phase(&self, phase: FramePhase)

Move the transport to a new FramePhase, adjusting the receive frame-size cap (WIRE-001). Default no-op — transports that do not length-prefix / buffer, or are inherently bounded, need not implement it. Called once by the session machinery at the handshake → data-pump boundary. Adding this defaulted method is source-compatible for every existing impl.
Source§

fn set_outbound_cid(&self, _cid: [u8; 8])

Stamp this transport’s outbound routing CID (ε / WIRE v5). Called once by the session machinery at the handshake → data-pump boundary with the session’s current_outbound_cid() (the rotating CID_0), switching the transport off the bootstrap ConnId onto the chain. Default no-op — socket-routed transports (TCP / WebSocket / WASI / Embedded) carry no on-wire CID and ignore it. Source-compatible for every existing impl.
Source§

fn has_migration_candidate(&self) -> bool

Whether the transport has observed an unvalidated candidate source for this session — a connection-migration signal (Phase 4). Only an address-aware transport (the UDP server) ever returns true; stream transports (TCP / WebSocket / WASI / Embedded) have no migration and use the default false. Deliberately SocketAddr-free so the generic data pump that calls it stays no_std-clean (std::net::SocketAddr does not exist in core/alloc); the candidate address is held inside the concrete transport.
Source§

fn send_to_candidate( &self, _data: &[u8], ) -> impl Future<Output = Result<bool, CoreError>> + Send

Send data — an already-encrypted PATH_VALIDATION challenge built by the session — to the transport’s internally-tracked candidate source, distinct from the established peer, under the transport’s own anti-amplification cap (RFC 9000 §8.2). Returns Ok(true) if a candidate existed and the send was within budget, Ok(false) otherwise (no candidate, or the 3× cap was hit). Default (non-address transports): a no-op Ok(false). The candidate address never crosses this boundary, keeping the trait no_std-safe.
Source§

fn confirm_authenticated_source(&self)

Commit the most-recently-received frame’s source as the migration candidate — call ONLY from the post-decrypt path, i.e. once that frame has been AEAD-verified (M-1). On the address-aware UDP server this is the migration-integrity fix: the candidate (and hence the server’s PATH_CHALLENGE target) is only ever an AEAD-authenticated source, so a spoofed CID-matched datagram (which never decrypts) cannot clobber the candidate slot and misdirect / stall a legitimate migration. SocketAddr-free — the address stays inside the concrete transport. Default no-op for transports without migration.
Source§

fn promote_candidate(&self) -> bool

Promote the migration candidate to the established peer (Phase 4, the switch): after the candidate’s path validates, subsequent app data and retransmits go to it instead of the old peer. Returns true if a candidate was promoted. Default no-op (false) for transports without migration. SocketAddr-free — the address is internal to the concrete transport.
Source§

fn migrate( &self, _local_addr: String, ) -> impl Future<Output = Result<(), CoreError>> + Send

Migrate this transport to a new local address (Phase 4 / P4.2c — embedder- triggered connection migration). The address crosses as a String (parsed inside the concrete native transport) so the trait stays SocketAddr-free and no_std-clean — std::net::SocketAddr does not exist in core/alloc. Best-effort: a parse / bind / connect failure returns Err and the session is expected to keep running on its existing socket — migration never tears it down. Default no-op Ok(()) for transports without migration (TCP / WebSocket / WASI / Embedded / the in-memory test pipe); only the native UDP client implements it.
Source§

fn migrate_server( &self, _local_addr: String, ) -> impl Future<Output = Result<(), CoreError>> + Send

Migrate the server side of this transport to a new local send address — the mirror of migrate for the accepting peer. The server binds a fresh local socket, sends subsequent server→client datagrams from it (so the client sees a new s2c source and follows it), and receives on it too (so once the client switches its send target the c2s frames are delivered transparently). The address crosses as a String to keep the trait SocketAddr-free / no_std-clean. Best-effort: a parse / bind failure returns Err and the session keeps running on the old socket. Default no-op Ok(()) — only the native UDP server implements it. Kept distinct from migrate so the FFI-exported client migrate() cannot trigger a server migration.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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