Skip to main content

Fragmenter

Struct Fragmenter 

Source
pub struct Fragmenter<'a> { /* private fields */ }
Expand description

Cuts a data block into the fragments of a session, and builds the coded ones.

The block is left where it is: nothing is copied until a fragment is asked for.

Implementations§

Source§

impl<'a> Fragmenter<'a>

Source

pub fn new( block: &'a [u8], frag_size: u8, ) -> Result<Fragmenter<'a>, LorawanError>

Prepares a block for a session.

§Arguments
  • block - the data to send.
  • frag_size - how many bytes each fragment carries.
§Returns

The fragmenter, which says how many fragments the block takes and how much padding the last one needs.

§Errors

LorawanError::MalformedFrame for a fragment size of zero or a block that needs more than MAX_FRAGMENTS fragments.

Source

pub const fn nb_frag(&self) -> u16

How many uncoded fragments the block was cut into.

§Returns

The count, which the session setup carries as NbFrag.

Source

pub const fn padding(&self) -> u8

How many bytes of padding the last fragment carries.

§Returns

The count, which the session setup carries and the receiver strips.

Source

pub const fn frag_size(&self) -> u8

How many bytes each fragment carries.

§Returns

The size.

Source

pub fn fragment(&self, n: u16, out: &mut [u8]) -> Result<usize, LorawanError>

Builds one fragment of the session.

§Arguments
  • n - which fragment, counting from one. Up to nb_frag it is a piece of the block; past that it is a coded fragment, the exclusive-or of a pseudo-random half of the pieces.
  • out - where to write it, at least frag_size bytes.
§Returns

How many bytes were written, which is always frag_size.

§Errors

LorawanError::MalformedFrame for a fragment number of zero, and LorawanError::PayloadTooLong when the buffer is too small.

Trait Implementations§

Source§

impl<'a> Clone for Fragmenter<'a>

Source§

fn clone(&self) -> Fragmenter<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Fragmenter<'a>

Source§

impl<'a> Debug for Fragmenter<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Fragmenter<'a>

§

impl<'a> RefUnwindSafe for Fragmenter<'a>

§

impl<'a> Send for Fragmenter<'a>

§

impl<'a> Sync for Fragmenter<'a>

§

impl<'a> Unpin for Fragmenter<'a>

§

impl<'a> UnsafeUnpin for Fragmenter<'a>

§

impl<'a> UnwindSafe for Fragmenter<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.