Merge pull request 'Added additional converter method' (#108) from msgs-to-user-converter-method into main
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
Reviewed-on: #108
This commit is contained in:
commit
cd77b806fe
@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Added generic sequence counter module.
|
- Added generic sequence counter module.
|
||||||
- Added `MsgToUserTlv::to_tlv` converter which reduced the type and converts
|
- Added `MsgToUserTlv::to_tlv` converter which reduced the type and converts
|
||||||
it to a generic `Tlv`.
|
it to a generic `Tlv`.
|
||||||
|
- Implemented `From<MsgToUserTlv> for Tlv` converter trait.
|
||||||
|
|
||||||
## Added and Changed
|
## Added and Changed
|
||||||
|
|
||||||
|
@ -88,6 +88,12 @@ impl<'data> MsgToUserTlv<'data> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> From<MsgToUserTlv<'a>> for Tlv<'a> {
|
||||||
|
fn from(value: MsgToUserTlv<'a>) -> Tlv<'a> {
|
||||||
|
value.to_tlv()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl WritableTlv for MsgToUserTlv<'_> {
|
impl WritableTlv for MsgToUserTlv<'_> {
|
||||||
fn len_written(&self) -> usize {
|
fn len_written(&self) -> usize {
|
||||||
self.len_full()
|
self.len_full()
|
||||||
@ -163,6 +169,14 @@ mod tests {
|
|||||||
assert_eq!(tlv.value(), custom_value);
|
assert_eq!(tlv.value(), custom_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_msg_to_user_to_tlv() {
|
||||||
|
let custom_value: [u8; 4] = [1, 2, 3, 4];
|
||||||
|
let msg_to_user = MsgToUserTlv::new(&custom_value).unwrap();
|
||||||
|
let tlv: Tlv = msg_to_user.into();
|
||||||
|
assert_eq!(msg_to_user.to_tlv(), tlv);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_msg_to_user_owner_converter() {
|
fn test_msg_to_user_owner_converter() {
|
||||||
let custom_value: [u8; 4] = [1, 2, 3, 4];
|
let custom_value: [u8; 4] = [1, 2, 3, 4];
|
||||||
|
Loading…
Reference in New Issue
Block a user