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§
Required Methods§
Sourcefn number_of_segments(&self) -> usize
fn number_of_segments(&self) -> usize
Current number of lost segments stored.
Sourcefn supports_large_file_size(&self) -> bool
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.
fn capacity(&self) -> Option<usize>
fn reset(&mut self)
Sourcefn segment_in_store(&self, segment: (u64, u64)) -> bool
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.
Sourcefn add_lost_segment(
&mut self,
lost_seg: (u64, u64),
) -> Result<(), LostSegmentError>
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.
Sourcefn remove_lost_segment(
&mut self,
segment_to_remove: (u64, u64),
) -> Result<bool, LostSegmentError>
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.
Sourcefn coalesce_lost_segments(&mut self) -> Result<(), LostSegmentError>
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§
fn is_empty(&self) -> bool
Sourcefn write_segments_to_bytes(
&self,
buf: &mut [u8],
file_flag: LargeFileFlag,
) -> Result<usize, LostSegmentWriteError>
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).
Sourcefn write_to_nak_segment_list(
&self,
nak_builder: &mut NakPduCreatorWithReservedSeqReqsBuf<'_>,
first_segment_request_for_metadata: bool,
) -> Result<usize, LostSegmentWriteError>
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.
impl LostSegmentStore for LostSegmentsList
alloc only.