Skip to main content

Reassembler

Struct Reassembler 

Source
pub struct Reassembler { /* private fields */ }
Expand description

Incremental reassembler for one direction of a connection.

A session reads one frame at a time and owns a Reassembler; reassemble_binary is the same validation for a sequence that is already in hand. Both allow only one fragmented message in flight, as the protocol requires.

Implementations§

Source§

impl Reassembler

Source

pub fn new(max_message_len: usize) -> Self

Creates a reassembler that rejects a reassembled message longer than max_message_len.

A session usually passes MAX_REASSEMBLED_LEN, the bound a receiver may choose for itself.

Source

pub fn push(&mut self, frame: &[u8]) -> Result<Option<(u8, Vec<u8>)>>

Feeds one Noise transport plaintext.

Returns Some((id, payload)) when the frame completes a message: immediately for a plain frame, and on the fragment that carries the last flag for a sequence. Every other fragment returns Ok(None).

§Errors

Returns an error, and drops any message in flight, for the malformed sequences the protocol defines: an empty frame, a plain frame while a fragmented message is in flight, a fragment without its flags byte, reserved flag bits, a continuation fragment without a first fragment, a second first fragment while one is in flight, a first fragment without its original message id, an original id of BINARY_MESSAGE_ID_FRAGMENT, and a message larger than max_message_len.

The framing carries no byte count and no sequence number, so a fragment lost from the middle of a message cannot be detected here.

Trait Implementations§

Source§

impl Debug for Reassembler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.