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>
impl<'c, 'n: 'c, 'a: 'n> Conn<'c, 'n, 'a>
Sourcepub fn recv(&mut self, buf: &mut [u8]) -> Result<usize, Error>
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.
Sourcepub fn send(&mut self, data: &[u8]) -> Result<usize, Error>
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.