pub struct Stream<'n, 'a: 'n> { /* private fields */ }Expand description
One outbound TCP connection, held as a capability. See Net::connect.
Borrows its Net, so the tag counter has one owner while the connection is open.
Implementations§
Source§impl<'n, 'a: 'n> Stream<'n, 'a>
impl<'n, 'a: 'n> Stream<'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, and return how many bytes.
Zero means nothing has arrived yet, exactly as for Conn::recv: TCP delivers when it
delivers, and a caller that needs more waits a little and asks again. A connection the peer
closed and that has been read to the end is released by net-stack, after which this returns
Error::Revoked - that is the end of the stream.
One call moves at most 4095 bytes, one message, so a buffer of 4 KiB is what a download wants.
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 up to 1024 bytes and return how many were ACCEPTED, which may be fewer, or none while
net-stack’s send buffer is full. Send the rest on a later call; nothing is dropped silently.
Authority: this connection’s WRITE right.
Sourcepub fn close(self) -> Result<(), Error>
pub fn close(self) -> Result<(), Error>
Close the connection: net-stack sends what is still queued, then its FIN.
Consumes the handle. Dropping also closes, and cannot report the outcome.
Sourcepub fn take_held(&mut self) -> Option<Message>
pub fn take_held(&mut self) -> Option<Message>
Take one message that arrived during an operation and was NOT the reply. See
Socket::take_held.