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>
impl<S: SSDVPacket> Encoder<'_, S>
Sourcepub fn new(systematic_packets: &mut [S]) -> Result<Encoder<'_, S>, EncoderError>
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.
Sourcepub fn encode(&self, packet_id: u16, output: &mut S)
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.