Skip to main content

TcpSession

Struct TcpSession 

Source
pub struct TcpSession { /* private fields */ }
Expand description

Tracks an active guest-originated TCP stream.

Implementations§

Source§

impl TcpSession

Source

pub fn owner_id(&self) -> u32

Correlation ID whose relay client owns this TCP stream.

Source

pub async fn write_data(&self, data: Vec<u8>) -> Result<(), String>

Queue stream data to write to the guest socket.

Awaits queue space when the per-session relay is behind, so a stalled destination backpressures the caller instead of growing memory.

Source

pub async fn close_write(&self) -> Result<(), String>

Close the guest socket write half.

Ordered after any queued data, so the destination sees the write shutdown only once it has received everything sent before it.

Source

pub fn close(&self)

Tear down the TCP session.

Aborts the relay task directly rather than queuing a command, so teardown never waits behind a full command queue. Dropping the task closes the guest socket. The host has already closed its side before asking for this, so no terminal frame is owed back to it.

Source

pub fn is_finished(&self) -> bool

Returns whether the background relay task has finished.

Source

pub fn open( id: u32, req: TcpConnect, session_tx: &UnboundedSender<(u32, SessionOutput)>, ) -> Self

Open a TCP stream from inside the guest and start relaying it.

The OS connect runs inside the spawned task, not on the caller’s serial loop, so a hanging or slow destination can never wedge the agent. The task reports core.tcp.connected on success or a terminal core.tcp.failed on error/timeout over session_tx; the host correlates either reply by id. The returned session is live immediately, with commands queued until the connect completes.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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