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 push_file(
&mut self,
file: Arc<File>,
offset: u64,
len: u64,
) -> Result<(), OutputFull>
pub fn push_file( &mut self, file: Arc<File>, offset: u64, len: u64, ) -> Result<(), OutputFull>
Queues len bytes of file from offset, sent zero copy where the OS can and
read in pieces otherwise (TLS, named pipes). Not counted against the budget; the
file stays open until the chunk has gone. Keep it from shrinking meanwhile: the
connection is reset with Io(FileTruncated) if it does. A read on TLS or a pipe
happens on the worker’s thread, so a slow disk holds that worker.
§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.