Skip to main content

Reassembler

Struct Reassembler 

Source
pub struct Reassembler {
    segs: Vec<(u32, Vec<u8>)>,
    bytes: usize,
}
Expand description

順序外セグメントを seq 昇順で保持する。

Fields§

§segs: Vec<(u32, Vec<u8>)>

(seq, data) を seq 昇順で保持する。

§bytes: usize

Implementations§

Source§

impl Reassembler

Source

pub fn new() -> Self

Source

pub const fn new_const() -> Self

static 配列の初期化用(const 文脈で使える)。

Source

pub fn len(&self) -> usize

保持中のセグメント数。

Source

pub fn is_empty(&self) -> bool

Source

pub fn bytes(&self) -> usize

保持中の合計バイト数。

Source

pub fn insert( &mut self, seq: u32, data: &[u8], ) -> Result<InsertOutcome, ReassemblyError>

順序外セグメントを保持する。

空ペイロードは黙って戻らず、エラーログを出して Err を返す (呼び出し側のバグを握り潰さないため)。

Source

pub fn pop_contiguous(&mut self, rcv_nxt: u32) -> (u32, Vec<u8>)

rcv_nxt から連続する分を取り出し、新しい rcv_nxt とデータを返す。

欠落が埋まった瞬間に、そこから繋がる全セグメントをまとめて返す。 連続していなければ空を返し rcv_nxt は据え置く。

Source

pub fn drop_before(&mut self, rcv_nxt: u32) -> usize

rcv_nxt より前(既に受信済み)のセグメントを捨て、捨てた数を返す。 再送で重複到着したものが溜まり続けるのを防ぐ。

Source

pub fn clear(&mut self)

全破棄(接続終了時など)。

Trait Implementations§

Source§

impl Debug for Reassembler

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Reassembler

Source§

fn default() -> Reassembler

Returns the “default value” for a type. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.