added packet ID trait impls
Some checks failed
Rust/spacepackets/pipeline/head There was a failure building this commit
Some checks failed
Rust/spacepackets/pipeline/head There was a failure building this commit
This commit is contained in:
parent
e935b3825a
commit
6ebdf7e330
@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [unreleased]
|
||||
|
||||
## Added
|
||||
|
||||
- `PacketId` trait impls: `Ord`, `PartialOrd` and `Hash`
|
||||
|
||||
# [v0.7.0-beta.1] 2023-08-28
|
||||
|
||||
- Bump `zerocopy` dependency to v0.7.0
|
||||
|
24
src/lib.rs
24
src/lib.rs
@ -62,7 +62,10 @@ extern crate alloc;
|
||||
extern crate std;
|
||||
|
||||
use crate::ecss::CCSDS_HEADER_LEN;
|
||||
use core::fmt::{Debug, Display, Formatter};
|
||||
use core::{
|
||||
fmt::{Debug, Display, Formatter},
|
||||
hash::Hash,
|
||||
};
|
||||
use crc::{Crc, CRC_16_IBM_3740};
|
||||
use delegate::delegate;
|
||||
|
||||
@ -195,6 +198,25 @@ pub struct PacketId {
|
||||
apid: u16,
|
||||
}
|
||||
|
||||
impl PartialOrd for PacketId {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
|
||||
self.raw().partial_cmp(&other.raw())
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for PacketId {
|
||||
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
|
||||
self.raw().cmp(&other.raw())
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for PacketId {
|
||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||
let raw = self.raw();
|
||||
raw.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PacketId {
|
||||
fn default() -> Self {
|
||||
PacketId {
|
||||
|
Loading…
Reference in New Issue
Block a user