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
impl Output
Sourcepub fn standalone(limit: u32) -> Output
pub fn standalone(limit: u32) -> Output
An output with its own budget, for tests of sessions (allocates).
Sourcepub fn push_partial(&mut self, bytes: &[u8]) -> usize
pub fn push_partial(&mut self, bytes: &[u8]) -> usize
Copies as much of bytes as the budget allows; returns how many were taken.
Sourcepub fn push_buffer(&mut self, buffer: Buffer) -> Result<(), OutputFull>
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.
Sourcepub fn push_static(&mut self, bytes: &'static [u8]) -> Result<(), OutputFull>
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.
Sourcepub fn begin_response(&mut self)
pub fn begin_response(&mut self)
Marks the start of a response (for the gate’s denial boundary).
Sourcepub fn begin_tagged_response(&mut self, tag: GateTag)
pub fn begin_tagged_response(&mut self, tag: GateTag)
Marks the start of a response and tags it for the gate (WriteCheck::response).
Sourcepub fn end_response(&mut self)
pub fn end_response(&mut self)
Marks the end of the response; clears the tag.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Output
impl RefUnwindSafe for Output
impl Send for Output
impl Sync for Output
impl Unpin for Output
impl UnsafeUnpin for Output
impl UnwindSafe for Output
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more