Skip to main content

Stream

Struct Stream 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'n, 'a: 'n> Drop for Stream<'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<'n, 'a> Freeze for Stream<'n, 'a>

§

impl<'n, 'a> !RefUnwindSafe for Stream<'n, 'a>

§

impl<'n, 'a> !Send for Stream<'n, 'a>

§

impl<'n, 'a> !Sync for Stream<'n, 'a>

§

impl<'n, 'a> Unpin for Stream<'n, 'a>

§

impl<'n, 'a> UnsafeUnpin for Stream<'n, 'a>

§

impl<'n, 'a> !UnwindSafe for Stream<'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.