pub struct Reassembly<'b> { /* private fields */ }Expand description
Joins the fragments of one message into a caller buffer.
Implementations§
Source§impl<'b> Reassembly<'b>
impl<'b> Reassembly<'b>
Sourcepub const fn new(buf: &'b mut [u8]) -> Self
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.
Sourcepub const fn expected(&self) -> Option<u8>
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).
Sourcepub fn push(
&mut self,
fragment: &Application<'_>,
) -> Result<Option<Application<'_>>>
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.