add segment metadata accessors
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
This commit is contained in:
parent
7e85ea7cd1
commit
d5f945305d
@ -43,6 +43,14 @@ impl<'seg_meta> SegmentMetadata<'seg_meta> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn record_continuation_state(&self) -> RecordContinuationState {
|
||||||
|
self.record_continuation_state
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn metadata(&self) -> Option<&'seg_meta [u8]> {
|
||||||
|
self.metadata
|
||||||
|
}
|
||||||
|
|
||||||
pub fn written_len(&self) -> usize {
|
pub fn written_len(&self) -> usize {
|
||||||
// Map empty metadata to 0 and slice to its length.
|
// Map empty metadata to 0 and slice to its length.
|
||||||
1 + self.metadata.map_or(0, |meta| meta.len())
|
1 + self.metadata.map_or(0, |meta| meta.len())
|
||||||
@ -162,9 +170,7 @@ impl<'seg_meta, 'file_data> FileDataPdu<'seg_meta, 'file_data> {
|
|||||||
self.segment_metadata.as_ref()
|
self.segment_metadata.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_bytes<'longest: 'seg_meta + 'file_data>(
|
pub fn from_bytes<'buf: 'seg_meta + 'file_data>(buf: &'buf [u8]) -> Result<Self, PduError> {
|
||||||
buf: &'longest [u8],
|
|
||||||
) -> Result<Self, PduError> {
|
|
||||||
let (pdu_header, mut current_idx) = PduHeader::from_bytes(buf)?;
|
let (pdu_header, mut current_idx) = PduHeader::from_bytes(buf)?;
|
||||||
let full_len_without_crc = pdu_header.verify_length_and_checksum(buf)?;
|
let full_len_without_crc = pdu_header.verify_length_and_checksum(buf)?;
|
||||||
let min_expected_len = current_idx + core::mem::size_of::<u32>();
|
let min_expected_len = current_idx + core::mem::size_of::<u32>();
|
||||||
|
Loading…
Reference in New Issue
Block a user