Skip to main content

Reassembly

Struct Reassembly 

Source
pub struct Reassembly<'b> { /* private fields */ }
Expand description

Joins the fragments of one message into a caller buffer.

Implementations§

Source§

impl<'b> Reassembly<'b>

Source

pub const fn new(buf: &'b mut [u8]) -> Self

Reassemble into buf. OMS limits a message to 16 KiB; size buf for the longest message the meters send.

Source

pub const fn expected(&self) -> Option<u8>

The fragment ID expected next, or None while no message is open (the next one must be fragment 1).

Source

pub const fn len(&self) -> usize

The bytes collected so far.

Source

pub const fn is_empty(&self) -> bool

Whether nothing has been collected.

Source

pub fn reset(&mut self)

Drop a message in progress.

Source

pub fn push( &mut self, fragment: &Application<'_>, ) -> Result<Option<Application<'_>>>

Add a fragment. Ok(None) while more are expected; the whole message, parsed, after the last one.

Fragment 1 always starts a new message (a meter or gateway that starts over, OMS Vol. 2 Annex L.4). Any other fragment must be the expected one from the same meter: otherwise Error::UnexpectedFragment (missing, repeated, out of order, or not a fragment at all: found 0) or Error::FragmentFromOtherMeter, and the message in progress is kept, so the caller can request the fragment again. A message longer than the buffer is Error::OutputTooSmall, one whose length differs from the length announced in fragment 1 Error::InvalidLength; both drop the message.

Trait Implementations§

Source§

impl<'b> Debug for Reassembly<'b>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b> !UnwindSafe for Reassembly<'b>

§

impl<'b> Forget for Reassembly<'b>

§

impl<'b> Freeze for Reassembly<'b>

§

impl<'b> Move for Reassembly<'b>

§

impl<'b> RefUnwindSafe for Reassembly<'b>

§

impl<'b> Send for Reassembly<'b>

§

impl<'b> Sync for Reassembly<'b>

§

impl<'b> Unpin for Reassembly<'b>

§

impl<'b> UnsafeUnpin for Reassembly<'b>

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.