#[non_exhaustive]pub struct LinesCodec { /* private fields */ }Expand description
Lines codec. Reads/writes line delimited strings.
Will split input up by LF or CRLF delimiters. Carriage return characters at the end of lines are not preserved.
§Security
When used with untrusted input, it is recommended to set a maximum line length with
LinesCodec::new_with_max_length. Without a length limit, the internal read buffer can grow
without bound if a peer sends an unbounded amount of data without a \n, potentially leading
to memory exhaustion (DoS).
Implementations§
Source§impl LinesCodec
impl LinesCodec
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new LinesCodec with no maximum line length.
Consider using LinesCodec::new_with_max_length when working with untrusted input.
Sourcepub const fn new_with_max_length(max_length: usize) -> Self
pub const fn new_with_max_length(max_length: usize) -> Self
Creates a new LinesCodec with a maximum line length, in bytes.
The limit applies to the bytes before the line delimiter (\n). If present, a trailing
carriage return (\r) in \r\n sequences is not counted towards the limit.
Using a length limit is recommended when working with untrusted input to avoid unbounded buffering.
Sourcepub const fn max_length(&self) -> usize
pub const fn max_length(&self) -> usize
Returns the maximum permitted line length, in bytes.
Trait Implementations§
Source§impl Clone for LinesCodec
impl Clone for LinesCodec
Source§fn clone(&self) -> LinesCodec
fn clone(&self) -> LinesCodec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more