copernica_packets/tag.rs
1use copernica_common::constants::TAG_SIZE;
2#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
3pub struct Tag(pub [u8; TAG_SIZE]);
4impl Tag {
5 pub fn as_bytes(&self) -> &[u8] {
6 &self.0[..]
7 }
8 pub fn from_bytes(data: &[u8]) -> Self {
9 let mut tag = [0u8; TAG_SIZE];
10 tag.clone_from_slice(&data[..TAG_SIZE]);
11 Self(tag)
12 }
13 pub fn new_empty_tag() -> Self{
14 let tag = [0u8; TAG_SIZE];
15 Self(tag)
16 }
17}