pub struct StdioConfig { /* private fields */ }Expand description
The settings both halves of the transport are built from.
Cloned into each adapter rather than shared by reference, so a
StdioSource and a StdioSink on the same session cannot be pointed at
different ceilings after the fact. The value is three words; the invariant is
worth more than the copy.
§Examples
use protocol_droid::adapters::primary::stdio::StdioConfig;
use protocol_droid::domain::MaxFrameSize;
// The default ceiling, with a smaller read buffer.
let config = StdioConfig::new(MaxFrameSize::new(64 * 1024)?).with_read_chunk(4096);
assert_eq!(config.read_chunk().get(), 4096);Implementations§
Source§impl StdioConfig
impl StdioConfig
Sourcepub const fn new(limit: MaxFrameSize) -> Self
pub const fn new(limit: MaxFrameSize) -> Self
The default configuration: a MaxFrameSize::DEFAULT ceiling and a
DEFAULT_READ_CHUNK read buffer.
Sourcepub const fn with_read_chunk(self, bytes: usize) -> Self
pub const fn with_read_chunk(self, bytes: usize) -> Self
Caps how many bytes one read from the peer’s stream may ask for.
Zero is treated as one byte rather than refused. A zero-length buffer
would make read return Ok(0), which every reader in the AsyncRead
contract reserves for end-of-stream — so honouring it would silently
turn the peer into a closed stream on the first poll. Coercing to one
byte keeps the loop making progress and costs nothing but syscalls.
Sourcepub const fn limit(self) -> MaxFrameSize
pub const fn limit(self) -> MaxFrameSize
The largest frame this transport will read or write.
Sourcepub const fn read_chunk(self) -> NonZeroUsize
pub const fn read_chunk(self) -> NonZeroUsize
How many bytes a single read may ask for.
Trait Implementations§
Source§impl Clone for StdioConfig
impl Clone for StdioConfig
impl Copy for StdioConfig
Source§impl Debug for StdioConfig
impl Debug for StdioConfig
Source§impl Default for StdioConfig
impl Default for StdioConfig
Source§fn default() -> Self
fn default() -> Self
The 4 MiB MaxFrameSize::DEFAULT ceiling.
Not a const impl, because Default::default is not a const fn and the
project’s rules prefer the trait over a hand-written constructor that
only exists to be called from another one.