[−][src]Struct tokio::codec::length_delimited::Builder
Configure length delimited LengthDelimitedCodec
s.
Builder
enables constructing configured length delimited codecs. 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]
impl Builder
pub fn new() -> Builder
[src]
pub fn new() -> Builder
Creates a new length delimited codec builder with default configuration values.
Examples
use tokio::codec::length_delimited::Builder; Builder::new() .length_field_offset(0) .length_field_length(2) .length_adjustment(0) .num_skip(0) .new_read(io);
ⓘImportant traits for &'a mut Wpub fn big_endian(&mut self) -> &mut Self
[src]
pub fn big_endian(&mut self) -> &mut Self
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::codec::length_delimited::Builder; Builder::new() .big_endian() .new_read(io);
ⓘImportant traits for &'a mut Wpub fn little_endian(&mut self) -> &mut Self
[src]
pub fn little_endian(&mut self) -> &mut Self
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::codec::length_delimited::Builder; Builder::new() .little_endian() .new_read(io);
ⓘImportant traits for &'a mut Wpub fn native_endian(&mut self) -> &mut Self
[src]
pub fn native_endian(&mut self) -> &mut Self
Read the length field as a native endian integer
The default setting is big endian.
This configuration option applies to both encoding and decoding.
Examples
use tokio::codec::length_delimited::Builder; Builder::new() .native_endian() .new_read(io);
ⓘImportant traits for &'a mut Wpub fn max_frame_length(&mut self, val: usize) -> &mut Self
[src]
pub fn max_frame_length(&mut self, val: usize) -> &mut Self
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::codec::length_delimited::Builder; Builder::new() .max_frame_length(8 * 1024) .new_read(io);
ⓘImportant traits for &'a mut Wpub fn length_field_length(&mut self, val: usize) -> &mut Self
[src]
pub fn length_field_length(&mut self, val: usize) -> &mut Self
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::codec::length_delimited::Builder; Builder::new() .length_field_length(4) .new_read(io);
ⓘImportant traits for &'a mut Wpub fn length_field_offset(&mut self, val: usize) -> &mut Self
[src]
pub fn length_field_offset(&mut self, val: usize) -> &mut Self
Sets the number of bytes in the header before the length field
This configuration option only applies to decoding.
Examples
use tokio::codec::length_delimited::Builder; Builder::new() .length_field_offset(1) .new_read(io);
ⓘImportant traits for &'a mut Wpub fn length_adjustment(&mut self, val: isize) -> &mut Self
[src]
pub fn length_adjustment(&mut self, val: isize) -> &mut Self
Delta between the payload length specified in the header and the real payload length
Examples
use tokio::codec::length_delimited::Builder; Builder::new() .length_adjustment(-2) .new_read(io);
ⓘImportant traits for &'a mut Wpub fn num_skip(&mut self, val: usize) -> &mut Self
[src]
pub fn num_skip(&mut self, val: usize) -> &mut Self
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::codec::length_delimited::Builder; Builder::new() .num_skip(4) .new_read(io);
pub fn new_codec(&self) -> LengthDelimitedCodec
[src]
pub fn new_codec(&self) -> LengthDelimitedCodec
Create a configured length delimited LengthDelimitedCodec
Examples
use tokio::codec::length_delimited::Builder; Builder::new() .length_field_offset(0) .length_field_length(2) .length_adjustment(0) .num_skip(0) .new_codec();
pub fn new_read<T>(&self, upstream: T) -> FramedRead<T, LengthDelimitedCodec> where
T: AsyncRead,
[src]
pub fn new_read<T>(&self, upstream: T) -> FramedRead<T, LengthDelimitedCodec> where
T: AsyncRead,
Create a configured length delimited FramedRead
Examples
use tokio::codec::length_delimited::Builder; Builder::new() .length_field_offset(0) .length_field_length(2) .length_adjustment(0) .num_skip(0) .new_read(io);
pub fn new_write<T>(&self, inner: T) -> FramedWrite<T, LengthDelimitedCodec> where
T: AsyncWrite,
[src]
pub fn new_write<T>(&self, inner: T) -> FramedWrite<T, LengthDelimitedCodec> where
T: AsyncWrite,
Create a configured length delimited FramedWrite
Examples
length_delimited::Builder::new() .length_field_length(2) .new_write(io);
pub fn new_framed<T>(&self, inner: T) -> Framed<T, LengthDelimitedCodec> where
T: AsyncRead + AsyncWrite,
[src]
pub fn new_framed<T>(&self, inner: T) -> Framed<T, LengthDelimitedCodec> where
T: AsyncRead + AsyncWrite,
Create a configured length delimited Framed
Examples
length_delimited::Builder::new() .length_field_length(2) .new_framed(io);
Trait Implementations
impl Clone for Builder
[src]
impl Clone for Builder
fn clone(&self) -> Builder
[src]
fn clone(&self) -> Builder
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for Builder
[src]
impl Copy for Builder
impl Debug for Builder
[src]
impl Debug for Builder
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
ⓘImportant traits for &'a mut Wfn borrow(&self) -> &T
[src]
fn borrow(&self) -> &T
Immutably borrows from an owned value. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
ⓘImportant traits for &'a mut Wfn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
[src]
impl<T> Erased for T