Skip to main content

Output

Struct Output 

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

What the session wants written: a bounded queue of chunks.

let mut out = net_io::Output::standalone(64 * 1024);
out.push(b"hello ").unwrap();
out.push_static(b"world").unwrap();
assert_eq!(out.pending(), 11);

Implementations§

Source§

impl Output

Source

pub fn standalone(limit: u32) -> Output

An output with its own budget, for tests of sessions (allocates).

Source

pub fn push_partial(&mut self, bytes: &[u8]) -> usize

Copies as much of bytes as the budget allows; returns how many were taken.

Source

pub fn push(&mut self, bytes: &[u8]) -> Result<(), OutputFull>

Copies all of bytes, or nothing.

§Errors

OutputFull when the budget cannot take all of it.

Source

pub fn push_buffer(&mut self, buffer: Buffer) -> Result<(), OutputFull>

Moves an owned buffer in (no copy).

§Errors

OutputFull when the budget or the chunk limit is reached.

Source

pub fn push_static(&mut self, bytes: &'static [u8]) -> Result<(), OutputFull>

Queues a static slice (no copy, not counted against the budget).

§Errors

OutputFull when the chunk limit is reached.

Source

pub fn begin_response(&mut self)

Marks the start of a response (for the gate’s denial boundary).

Source

pub fn begin_tagged_response(&mut self, tag: GateTag)

Marks the start of a response and tags it for the gate (WriteCheck::response).

Source

pub fn end_response(&mut self)

Marks the end of the response; clears the tag.

Source

pub fn pending(&self) -> usize

Bytes queued and not yet sent.

Source

pub fn is_empty(&self) -> bool

Whether nothing is queued.

Source

pub fn wipe_all(&mut self)

Overwrites every pending chunk net-io owns with zeroes and drops it.

Trait Implementations§

Source§

impl Debug for Output

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.