-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d012f17
commit 5914ecb
Showing
21 changed files
with
183 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
use std::array::TryFromSliceError; | ||
|
||
use crate::{error::Error, Precision}; | ||
|
||
/// A clue that allows probabilistic message detection. | ||
#[derive(Debug, Clone)] | ||
pub struct Clue(pub [u8; 68]); | ||
pub struct Clue(pub(crate) [u8; 68]); | ||
|
||
impl Clue { | ||
/// The bits of precision for this `Clue`. | ||
pub fn precision_bits(&self) -> u8 { | ||
self.0[64] | ||
/// The bits of precision for this `Clue`, if valid. | ||
pub fn precision(&self) -> Result<Precision, Error> { | ||
self.0[64].try_into() | ||
} | ||
} | ||
|
||
impl From<Clue> for Vec<u8> { | ||
fn from(value: Clue) -> Self { | ||
value.0.into() | ||
} | ||
} | ||
|
||
impl TryFrom<&[u8]> for Clue { | ||
type Error = TryFromSliceError; | ||
|
||
fn try_from(value: &[u8]) -> Result<Self, Self::Error> { | ||
Ok(Self(value.try_into()?)) | ||
} | ||
} |
Oops, something went wrong.