Skip to content

Commit

Permalink
Merge pull request 'add segment metadata accessors' (#46) from seg-me…
Browse files Browse the repository at this point in the history
…tadata-accessors into main

Reviewed-on: https://egit.irs.uni-stuttgart.de/rust/spacepackets/pulls/46
  • Loading branch information
robamu committed Dec 3, 2023
2 parents 5205cc0 + f11a23c commit 834d56c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/cfdp/pdu/file_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// Map empty metadata to 0 and slice to its length.
1 + self.metadata.map_or(0, |meta| meta.len())
Expand Down Expand Up @@ -162,9 +170,7 @@ impl<'seg_meta, 'file_data> FileDataPdu<'seg_meta, 'file_data> {
self.segment_metadata.as_ref()
}

pub fn from_bytes<'longest: 'seg_meta + 'file_data>(
buf: &'longest [u8],
) -> Result<Self, PduError> {
pub fn from_bytes<'buf: 'seg_meta + 'file_data>(buf: &'buf [u8]) -> Result<Self, PduError> {
let (pdu_header, mut current_idx) = PduHeader::from_bytes(buf)?;
let full_len_without_crc = pdu_header.verify_length_and_checksum(buf)?;
let min_expected_len = current_idx + core::mem::size_of::<u32>();
Expand Down

0 comments on commit 834d56c

Please sign in to comment.