better names for lifetimes
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
78c5787e07
commit
09b305f529
16
src/tc.rs
16
src/tc.rs
@ -215,19 +215,19 @@ impl PusTcSecondaryHeader {
|
|||||||
/// There is no spare bytes support yet.
|
/// There is no spare bytes support yet.
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PusTc<'slice> {
|
pub struct PusTc<'app_data> {
|
||||||
sp_header: SpHeader,
|
sp_header: SpHeader,
|
||||||
pub sec_header: PusTcSecondaryHeader,
|
pub sec_header: PusTcSecondaryHeader,
|
||||||
/// If this is set to false, a manual call to [PusTc::calc_own_crc16] or
|
/// If this is set to false, a manual call to [PusTc::calc_own_crc16] or
|
||||||
/// [PusTc::update_packet_fields] is necessary for the serialized or cached CRC16 to be valid.
|
/// [PusTc::update_packet_fields] is necessary for the serialized or cached CRC16 to be valid.
|
||||||
pub calc_crc_on_serialization: bool,
|
pub calc_crc_on_serialization: bool,
|
||||||
#[cfg_attr(feature = "serde", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
raw_data: Option<&'slice [u8]>,
|
raw_data: Option<&'app_data [u8]>,
|
||||||
app_data: Option<&'slice [u8]>,
|
app_data: Option<&'app_data [u8]>,
|
||||||
crc16: Option<u16>,
|
crc16: Option<u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'slice> PusTc<'slice> {
|
impl<'app_data> PusTc<'app_data> {
|
||||||
/// Generates a new struct instance.
|
/// Generates a new struct instance.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@ -243,7 +243,7 @@ impl<'slice> PusTc<'slice> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
sp_header: &mut SpHeader,
|
sp_header: &mut SpHeader,
|
||||||
sec_header: PusTcSecondaryHeader,
|
sec_header: PusTcSecondaryHeader,
|
||||||
app_data: Option<&'slice [u8]>,
|
app_data: Option<&'app_data [u8]>,
|
||||||
set_ccsds_len: bool,
|
set_ccsds_len: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
sp_header.set_packet_type(PacketType::Tc);
|
sp_header.set_packet_type(PacketType::Tc);
|
||||||
@ -268,7 +268,7 @@ impl<'slice> PusTc<'slice> {
|
|||||||
sph: &mut SpHeader,
|
sph: &mut SpHeader,
|
||||||
service: u8,
|
service: u8,
|
||||||
subservice: u8,
|
subservice: u8,
|
||||||
app_data: Option<&'slice [u8]>,
|
app_data: Option<&'app_data [u8]>,
|
||||||
set_ccsds_len: bool,
|
set_ccsds_len: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
@ -405,7 +405,7 @@ impl<'slice> PusTc<'slice> {
|
|||||||
|
|
||||||
/// Create a [PusTc] instance from a raw slice. On success, it returns a tuple containing
|
/// Create a [PusTc] instance from a raw slice. On success, it returns a tuple containing
|
||||||
/// the instance and the found byte length of the packet.
|
/// the instance and the found byte length of the packet.
|
||||||
pub fn from_bytes(slice: &'slice [u8]) -> Result<(Self, usize), PusError> {
|
pub fn from_bytes(slice: &'app_data [u8]) -> Result<(Self, usize), PusError> {
|
||||||
let raw_data_len = slice.len();
|
let raw_data_len = slice.len();
|
||||||
if raw_data_len < PUS_TC_MIN_LEN_WITHOUT_APP_DATA {
|
if raw_data_len < PUS_TC_MIN_LEN_WITHOUT_APP_DATA {
|
||||||
return Err(PusError::RawDataTooShort(raw_data_len));
|
return Err(PusError::RawDataTooShort(raw_data_len));
|
||||||
@ -435,7 +435,7 @@ impl<'slice> PusTc<'slice> {
|
|||||||
Ok((pus_tc, total_len))
|
Ok((pus_tc, total_len))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn raw(&self) -> Option<&'slice [u8]> {
|
pub fn raw(&self) -> Option<&'app_data [u8]> {
|
||||||
self.raw_data
|
self.raw_data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
src/tm.rs
35
src/tm.rs
@ -108,18 +108,18 @@ pub mod zc {
|
|||||||
|
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PusTmSecondaryHeader<'slice> {
|
pub struct PusTmSecondaryHeader<'stamp> {
|
||||||
pus_version: PusVersion,
|
pus_version: PusVersion,
|
||||||
pub sc_time_ref_status: u8,
|
pub sc_time_ref_status: u8,
|
||||||
pub service: u8,
|
pub service: u8,
|
||||||
pub subservice: u8,
|
pub subservice: u8,
|
||||||
pub msg_counter: u16,
|
pub msg_counter: u16,
|
||||||
pub dest_id: u16,
|
pub dest_id: u16,
|
||||||
pub time_stamp: &'slice [u8],
|
pub time_stamp: &'stamp [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'slice> PusTmSecondaryHeader<'slice> {
|
impl<'stamp> PusTmSecondaryHeader<'stamp> {
|
||||||
pub fn new_simple(service: u8, subservice: u8, time_stamp: &'slice [u8]) -> Self {
|
pub fn new_simple(service: u8, subservice: u8, time_stamp: &'stamp [u8]) -> Self {
|
||||||
PusTmSecondaryHeader {
|
PusTmSecondaryHeader {
|
||||||
pus_version: PusVersion::PusC,
|
pus_version: PusVersion::PusC,
|
||||||
sc_time_ref_status: 0,
|
sc_time_ref_status: 0,
|
||||||
@ -136,7 +136,7 @@ impl<'slice> PusTmSecondaryHeader<'slice> {
|
|||||||
subservice: u8,
|
subservice: u8,
|
||||||
msg_counter: u16,
|
msg_counter: u16,
|
||||||
dest_id: u16,
|
dest_id: u16,
|
||||||
time_stamp: &'slice [u8],
|
time_stamp: &'stamp [u8],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
PusTmSecondaryHeader {
|
PusTmSecondaryHeader {
|
||||||
pus_version: PusVersion::PusC,
|
pus_version: PusVersion::PusC,
|
||||||
@ -203,19 +203,19 @@ impl<'slice> TryFrom<zc::PusTmSecHeader<'slice>> for PusTmSecondaryHeader<'slice
|
|||||||
/// There is no spare bytes support yet.
|
/// There is no spare bytes support yet.
|
||||||
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PusTm<'slice> {
|
pub struct PusTm<'src_data> {
|
||||||
pub sp_header: SpHeader,
|
pub sp_header: SpHeader,
|
||||||
pub sec_header: PusTmSecondaryHeader<'slice>,
|
pub sec_header: PusTmSecondaryHeader<'src_data>,
|
||||||
/// If this is set to false, a manual call to [PusTm::calc_own_crc16] or
|
/// If this is set to false, a manual call to [PusTm::calc_own_crc16] or
|
||||||
/// [PusTm::update_packet_fields] is necessary for the serialized or cached CRC16 to be valid.
|
/// [PusTm::update_packet_fields] is necessary for the serialized or cached CRC16 to be valid.
|
||||||
pub calc_crc_on_serialization: bool,
|
pub calc_crc_on_serialization: bool,
|
||||||
#[cfg_attr(feature = "serde", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
raw_data: Option<&'slice [u8]>,
|
raw_data: Option<&'src_data [u8]>,
|
||||||
source_data: Option<&'slice [u8]>,
|
source_data: Option<&'src_data [u8]>,
|
||||||
crc16: Option<u16>,
|
crc16: Option<u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'slice> PusTm<'slice> {
|
impl<'src_data> PusTm<'src_data> {
|
||||||
/// Generates a new struct instance.
|
/// Generates a new struct instance.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@ -228,10 +228,15 @@ impl<'slice> PusTm<'slice> {
|
|||||||
/// * `set_ccsds_len` - Can be used to automatically update the CCSDS space packet data length
|
/// * `set_ccsds_len` - Can be used to automatically update the CCSDS space packet data length
|
||||||
/// field. If this is not set to true, [PusTm::update_ccsds_data_len] can be called to set
|
/// field. If this is not set to true, [PusTm::update_ccsds_data_len] can be called to set
|
||||||
/// the correct value to this field manually
|
/// the correct value to this field manually
|
||||||
|
///
|
||||||
|
/// # Lifetimes
|
||||||
|
///
|
||||||
|
/// * `'src_data` - Life time of a buffer where the time stamp and then user source data will
|
||||||
|
/// be serialized into.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
sp_header: &mut SpHeader,
|
sp_header: &mut SpHeader,
|
||||||
sec_header: PusTmSecondaryHeader<'slice>,
|
sec_header: PusTmSecondaryHeader<'src_data>,
|
||||||
source_data: Option<&'slice [u8]>,
|
source_data: Option<&'src_data [u8]>,
|
||||||
set_ccsds_len: bool,
|
set_ccsds_len: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
sp_header.set_packet_type(PacketType::Tm);
|
sp_header.set_packet_type(PacketType::Tm);
|
||||||
@ -259,11 +264,11 @@ impl<'slice> PusTm<'slice> {
|
|||||||
length
|
length
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn time_stamp(&self) -> &'slice [u8] {
|
pub fn time_stamp(&self) -> &'src_data [u8] {
|
||||||
self.sec_header.time_stamp
|
self.sec_header.time_stamp
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn source_data(&self) -> Option<&'slice [u8]> {
|
pub fn source_data(&self) -> Option<&'src_data [u8]> {
|
||||||
self.source_data
|
self.source_data
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +395,7 @@ impl<'slice> PusTm<'slice> {
|
|||||||
/// the instance and the found byte length of the packet. The timestamp length needs to be
|
/// the instance and the found byte length of the packet. The timestamp length needs to be
|
||||||
/// known beforehand.
|
/// known beforehand.
|
||||||
pub fn from_bytes(
|
pub fn from_bytes(
|
||||||
slice: &'slice [u8],
|
slice: &'src_data [u8],
|
||||||
timestamp_len: usize,
|
timestamp_len: usize,
|
||||||
) -> Result<(Self, usize), PusError> {
|
) -> Result<(Self, usize), PusError> {
|
||||||
let raw_data_len = slice.len();
|
let raw_data_len = slice.len();
|
||||||
|
Loading…
Reference in New Issue
Block a user