Struct tokio_io::codec::length_delimited::Builder
[−]
[src]
pub struct Builder { /* fields omitted */ }
Configure length delimited FramedRead
, FramedWrite
, and Framed
values.
Builder
enables constructing configured length delimited framers. Note
that not all configuration settings apply to both encoding and decoding. See
the documentation for specific methods for more detail.
Methods
impl Builder
[src]
fn new() -> Builder
[src]
Creates a new length delimited framer builder with default configuration values.
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .length_field_offset(0) .length_field_length(2) .length_adjustment(0) .num_skip(0) .new_read(io);
fn big_endian(&mut self) -> &mut Self
[src]
Read the length field as a big endian integer
This is the default setting.
This configuration option applies to both encoding and decoding.
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .big_endian() .new_read(io);
fn little_endian(&mut self) -> &mut Self
[src]
Read the length field as a little endian integer
The default setting is big endian.
This configuration option applies to both encoding and decoding.
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .little_endian() .new_read(io);
fn max_frame_length(&mut self, val: usize) -> &mut Self
[src]
Sets the max frame length
This configuration option applies to both encoding and decoding. The default value is 8MB.
When decoding, the length field read from the byte stream is checked against this setting before any adjustments are applied. When encoding, the length of the submitted payload is checked against this setting.
When frames exceed the max length, an io::Error
with the custom value
of the FrameTooBig
type will be returned.
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .max_frame_length(8 * 1024) .new_read(io);
fn length_field_length(&mut self, val: usize) -> &mut Self
[src]
Sets the number of bytes used to represent the length field
The default value is 4
. The max value is 8
.
This configuration option applies to both encoding and decoding.
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .length_field_length(4) .new_read(io);
fn length_field_offset(&mut self, val: usize) -> &mut Self
[src]
Sets the number of bytes in the header before the length field
This configuration option only applies to decoding.
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .length_field_offset(1) .new_read(io);
fn length_adjustment(&mut self, val: isize) -> &mut Self
[src]
Delta between the payload length specified in the header and the real payload length
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .length_adjustment(-2) .new_read(io);
fn num_skip(&mut self, val: usize) -> &mut Self
[src]
Sets the number of bytes to skip before reading the payload
Default value is length_field_len + length_field_offset
This configuration option only applies to decoding
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .num_skip(4) .new_read(io);
fn new_read<T>(&self, upstream: T) -> FramedRead<T> where
T: AsyncRead,
[src]
T: AsyncRead,
Create a configured length delimited FramedRead
Examples
use tokio_io::codec::length_delimited::Builder; Builder::new() .length_field_offset(0) .length_field_length(2) .length_adjustment(0) .num_skip(0) .new_read(io);
fn new_write<T, B>(&self, inner: T) -> FramedWrite<T, B> where
T: AsyncWrite,
B: IntoBuf,
[src]
T: AsyncWrite,
B: IntoBuf,
Create a configured length delimited FramedWrite
Examples
length_delimited::Builder::new() .length_field_length(2) .new_write(io);
fn new_framed<T, B>(&self, inner: T) -> Framed<T, B> where
T: AsyncRead + AsyncWrite,
B: IntoBuf,
[src]
T: AsyncRead + AsyncWrite,
B: IntoBuf,
Create a configured length delimited Framed
Examples
length_delimited::Builder::new() .length_field_length(2) .new_framed(io);
Trait Implementations
impl Debug for Builder
[src]
impl Clone for Builder
[src]
fn clone(&self) -> Builder
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more