pub trait Stream: Send + Sync {
// Required methods
fn read(&self, buf: &mut [u8]) -> NetResult<usize>;
fn write_all(&self, buf: &[u8]) -> NetResult<()>;
fn set_timeouts(&self, read_ms: Option<u32>, write_ms: Option<u32>);
// Provided methods
fn shutdown(&self) { ... }
fn wait_readable(&self, _ms: u32) -> bool { ... }
fn end_is_clean(&self) -> bool { ... }
}Expand description
a byte stream HTTP runs over (shared between a reader and a writer: &self methods)
Required Methods§
Provided Methods§
Sourcefn wait_readable(&self, _ms: u32) -> bool
fn wait_readable(&self, _ms: u32) -> bool
whether bytes (or the end) can be read within ms
Sourcefn end_is_clean(&self) -> bool
fn end_is_clean(&self) -> bool
after read gave Ok(0): whether the peer ended the stream in order. TLS: only after its close_notify – a TCP end without one may be an attacker cutting a body that runs to the end of the connection (HTTP without a length). Plain streams: always
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".