Encoder

Struct Encoder 

Source
pub struct Encoder<'a, S> { /* private fields */ }
Expand description

SSDV FEC encoder.

This struct is used to encode an arbitrary number of packets for an SSDV image in a fountain-code-like manner. The encoder is initialized with Encoder::new by giving it the SSDV image packets. Afterwards, the Encoder::encode function can be called to generate a packet with an arbitrary packet_id.

The struct contains a mutable reference to a slice containing the SSDV packets of the image. The lifetime of this slice is given by the lifetime parameter 'a.

Implementations§

Source§

impl<S: SSDVPacket> Encoder<'_, S>

Source

pub fn new(systematic_packets: &mut [S]) -> Result<Encoder<'_, S>, EncoderError>

Creates a new FEC encoder for an SSDV image.

The systematic packets for the image are given in the slice systematic_packets. They must be in order and without repetitions. The encoder works in-place in this slice, modifying its contents.

If there is a problem with the input contents, this function returns an error. Otherwise, an Encoder struct on which encode can be called is returned.

Source

pub fn encode(&self, packet_id: u16, output: &mut S)

Generate the packet with a corresponding packet_id.

If the packet_id is smaller than the number of systematic packets in the image, the corresponding systematic packet give to Encoder::new is generated. Otherwise, a FEC packet is generated. The packet is written to output.

Trait Implementations§

Source§

impl<'a, S: Debug> Debug for Encoder<'a, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for Encoder<'a, S>

§

impl<'a, S> RefUnwindSafe for Encoder<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for Encoder<'a, S>
where S: Send,

§

impl<'a, S> Sync for Encoder<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for Encoder<'a, S>

§

impl<'a, S> !UnwindSafe for Encoder<'a, S>

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.