LostSegmentStore

Trait LostSegmentStore 

Source
pub trait LostSegmentStore {
    type Iter<'a>: Iterator<Item = (u64, u64)> + 'a
       where Self: 'a;

    // Required methods
    fn iter(&self) -> Self::Iter<'_>;
    fn number_of_segments(&self) -> usize;
    fn supports_large_file_size(&self) -> bool;
    fn capacity(&self) -> Option<usize>;
    fn reset(&mut self);
    fn segment_in_store(&self, segment: (u64, u64)) -> bool;
    fn add_lost_segment(
        &mut self,
        lost_seg: (u64, u64),
    ) -> Result<(), LostSegmentError>;
    fn remove_lost_segment(
        &mut self,
        segment_to_remove: (u64, u64),
    ) -> Result<bool, LostSegmentError>;
    fn coalesce_lost_segments(&mut self) -> Result<(), LostSegmentError>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn write_segments_to_bytes(
        &self,
        buf: &mut [u8],
        file_flag: LargeFileFlag,
    ) -> Result<usize, LostSegmentWriteError> { ... }
    fn write_to_nak_segment_list(
        &self,
        nak_builder: &mut NakPduCreatorWithReservedSeqReqsBuf<'_>,
        first_segment_request_for_metadata: bool,
    ) -> Result<usize, LostSegmentWriteError> { ... }
}
Expand description

Generic trait to model a lost segment store.

The destination handler can use this store to keep track of lost segments and re-requesting them. This abstraction allow using different data structures as a backend.

Required Associated Types§

Source

type Iter<'a>: Iterator<Item = (u64, u64)> + 'a where Self: 'a

Required Methods§

Source

fn iter(&self) -> Self::Iter<'_>

Iterate over all lost segments stored.

Source

fn number_of_segments(&self) -> usize

Current number of lost segments stored.

Source

fn supports_large_file_size(&self) -> bool

Implementations may explicitely omit support for large file segments to save memory if large file sizes are not used.

Source

fn capacity(&self) -> Option<usize>

Source

fn reset(&mut self)

Source

fn segment_in_store(&self, segment: (u64, u64)) -> bool

Checks whether a segment is already in the store.

Implementors should be check whether the provided segment is a subset of an existing segments.

Source

fn add_lost_segment( &mut self, lost_seg: (u64, u64), ) -> Result<(), LostSegmentError>

Add a new lost segment.

For efficiency reason, the implementors must not check whether the new segments already exists in the store which is provided by the Self::segment_in_store method.

Therefore, the caller must ensure that no duplicate segments are added.

Source

fn remove_lost_segment( &mut self, segment_to_remove: (u64, u64), ) -> Result<bool, LostSegmentError>

Remove a lost segment.

Implementors should also be able to remove lost segments which are a subset of an existing section but can return an error if an segment to remove only partially overlaps an existing segment.

Returns whether a segment was removed.

Source

fn coalesce_lost_segments(&mut self) -> Result<(), LostSegmentError>

The lost segment store may additionally have the capability to coalesce overlapping or adjacent segments.

Provided Methods§

Source

fn is_empty(&self) -> bool

Source

fn write_segments_to_bytes( &self, buf: &mut [u8], file_flag: LargeFileFlag, ) -> Result<usize, LostSegmentWriteError>

Write the segments to the raw byte format of the NAK PDU segment requests as specified by the CFDP standard 5.2.6.1 (NAK PDU).

Source

fn write_to_nak_segment_list( &self, nak_builder: &mut NakPduCreatorWithReservedSeqReqsBuf<'_>, first_segment_request_for_metadata: bool, ) -> Result<usize, LostSegmentWriteError>

Write the segments to the raw byte buffer of the supplied NAK builder.

Please note that this function only works if all the segment requests fit into the NAK builder buffer. In any other case, you should write a custom iteration and serialization sequence which spreads the lost segments across multiple packets.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl LostSegmentStore for LostSegmentsList

Available on crate feature alloc only.
Source§

type Iter<'a> = Cloned<Iter<'a, (u64, u64)>> where Self: 'a

Source§

impl<const N: usize> LostSegmentStore for LostSegmentsListHeapless<N, u32>

Source§

type Iter<'a> = Map<Iter<'a, (u32, u32)>, fn(&(u32, u32)) -> (u64, u64)> where Self: 'a

Source§

impl<const N: usize> LostSegmentStore for LostSegmentsListHeapless<N, u64>

Source§

type Iter<'a> = Cloned<Iter<'a, (u64, u64)>> where Self: 'a