decaf377_fmd/
clue.rs

1use std::array::TryFromSliceError;
2
3use crate::{error::Error, Precision};
4
5/// A clue that allows probabilistic message detection.
6#[derive(Debug, Clone)]
7pub struct Clue(pub(crate) [u8; 68]);
8
9impl Clue {
10    /// The bits of precision for this `Clue`, if valid.
11    pub fn precision(&self) -> Result<Precision, Error> {
12        self.0[64].try_into()
13    }
14}
15
16impl From<Clue> for Vec<u8> {
17    fn from(value: Clue) -> Self {
18        value.0.into()
19    }
20}
21
22impl TryFrom<&[u8]> for Clue {
23    type Error = TryFromSliceError;
24
25    fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
26        Ok(Self(value.try_into()?))
27    }
28}