added additional ctors which only set the APID #80
@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
to `new_for_tc_checked`, `new_for_tm_checked`, `new_for_unseg_tc_checked` and
|
to `new_for_tc_checked`, `new_for_tm_checked`, `new_for_unseg_tc_checked` and
|
||||||
`new_for_unseg_tm_checked`.
|
`new_for_unseg_tm_checked`.
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- `SpHeader::new_from_apid` and `SpHeader::new_from_apid_checked` constructor.
|
||||||
|
|
||||||
# [v0.11.0-rc.1] 2024-04-03
|
# [v0.11.0-rc.1] 2024-04-03
|
||||||
|
|
||||||
Major API changes for the time API. If you are using the time API, it is strongly recommended
|
Major API changes for the time API. If you are using the time API, it is strongly recommended
|
||||||
|
41
src/lib.rs
41
src/lib.rs
@ -512,6 +512,35 @@ impl SpHeader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This constructor sets the sequence flag field to [SequenceFlags::Unsegmented]. The data
|
||||||
|
/// length field is set to 1, which denotes an empty space packets.
|
||||||
|
///
|
||||||
|
/// This constructor will panic if the APID exceeds [MAX_APID].
|
||||||
|
pub const fn new_from_apid(apid: u16) -> Self {
|
||||||
|
SpHeader {
|
||||||
|
version: 0,
|
||||||
|
packet_id: PacketId::new(PacketType::Tm, false, apid),
|
||||||
|
psc: PacketSequenceCtrl {
|
||||||
|
seq_flags: SequenceFlags::Unsegmented,
|
||||||
|
seq_count: 0,
|
||||||
|
},
|
||||||
|
data_len: 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checked variant of [Self::new_from_apid].
|
||||||
|
pub fn new_from_apid_checked(apid: u16) -> Option<Self> {
|
||||||
|
Some(SpHeader {
|
||||||
|
version: 0,
|
||||||
|
packet_id: PacketId::new_checked(PacketType::Tm, false, apid)?,
|
||||||
|
psc: PacketSequenceCtrl {
|
||||||
|
seq_flags: SequenceFlags::Unsegmented,
|
||||||
|
seq_count: 0,
|
||||||
|
},
|
||||||
|
data_len: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// This constructor panics if the passed APID exceeds [MAX_APID] or the passed packet sequence
|
/// This constructor panics if the passed APID exceeds [MAX_APID] or the passed packet sequence
|
||||||
/// count exceeds [MAX_SEQ_COUNT].
|
/// count exceeds [MAX_SEQ_COUNT].
|
||||||
///
|
///
|
||||||
@ -1180,4 +1209,16 @@ pub(crate) mod tests {
|
|||||||
let mut id_set = HashSet::new();
|
let mut id_set = HashSet::new();
|
||||||
id_set.insert(PacketId::from(1_u16));
|
id_set.insert(PacketId::from(1_u16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sp_header_from_apid() {
|
||||||
|
let sp_header = SpHeader::new_from_apid(0x03);
|
||||||
|
assert_eq!(sp_header.apid(), 0x03);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sp_header_from_apid_checked() {
|
||||||
|
let sp_header = SpHeader::new_from_apid_checked(0x03).unwrap();
|
||||||
|
assert_eq!(sp_header.apid(), 0x03);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user