Skip to main content

Conn

Struct Conn 

Source
pub struct Conn<'c, 'n: 'c, 'a: 'n> { /* private fields */ }
Expand description

One accepted TCP connection, held as a capability.

Borrows its Listener, so one connection is open at a time and the tag counter has a single owner from Net down. That is serve’s real model - accept one, answer it, close, accept the next - now enforced rather than remembered.

Implementations§

Source§

impl<'c, 'n: 'c, 'a: 'n> Conn<'c, 'n, 'a>

Source

pub fn recv(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Read whatever has arrived, into buf. Returns how many bytes.

Zero means nothing has arrived YET, not end of stream - TCP delivers when it delivers, so a caller that wants more loops. Nothing here tells “nothing yet” from “the peer has gone”: is_closed reports only whether THIS handle was closed.

Any buffer size works: the request tells net-stack how much buf holds, and it takes no more than that off the connection, so nothing is read and then lost. One call moves at most 4095 bytes, one message. (Until 2026-10-10 it asked for everything and dropped what did not fit - backlog/fixed/80 G3.)

Authority: this connection’s READ right.

Source

pub fn send(&mut self, data: &[u8]) -> Result<usize, Error>

Send bytes. Returns how many were ACCEPTED, which may be fewer than offered.

A short send is reported, not hidden. net-stack’s send arena is fixed, so a caller offering more than fits must know how much was taken or it loses the tail without being told (26.7). Send the remainder on a later call.

Authority: this connection’s WRITE right.

Source

pub fn is_closed(&self) -> bool

Whether close has already been called on this handle.

Source

pub fn close(self) -> Result<(), Error>

Close the connection.

Consumes the handle. Dropping also closes, and cannot report the outcome.

Trait Implementations§

Source§

impl<'c, 'n: 'c, 'a: 'n> Drop for Conn<'c, 'n, 'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'c, 'n, 'a> Freeze for Conn<'c, 'n, 'a>

§

impl<'c, 'n, 'a> !RefUnwindSafe for Conn<'c, 'n, 'a>

§

impl<'c, 'n, 'a> !Send for Conn<'c, 'n, 'a>

§

impl<'c, 'n, 'a> !Sync for Conn<'c, 'n, 'a>

§

impl<'c, 'n, 'a> Unpin for Conn<'c, 'n, 'a>

§

impl<'c, 'n, 'a> UnsafeUnpin for Conn<'c, 'n, 'a>

§

impl<'c, 'n, 'a> !UnwindSafe for Conn<'c, 'n, 'a>

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.