#[non_exhaustive]pub enum RevealFormat {
Paper32,
Hex,
Bip39,
}Expand description
An encoding a value is shown in.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Paper32
Rows of 32 base-32 characters, 28 of data and 4 of parity, from an
alphabet without I, L, O and U; a wrong character in a row
is corrected, two unreadable ones recovered. The default. See
paper32.
Hex
Two hexadecimal digits per byte, upper case, in rows of 32.
Bip39
Words from the BIP-39 English list, one per row, as a hardware
wallet shows its recovery phrase and takes it back. For entropy of
16 to 32 bytes in steps of 4. See bip39.
Implementations§
Source§impl RevealFormat
impl RevealFormat
Sourcepub fn length_of(self, bytes: usize) -> usize
pub fn length_of(self, bytes: usize) -> usize
A value of bytes bytes in this format’s unit: bytes, or the words
of a phrase.
Sourcepub fn bytes_for(self, length: usize) -> usize
pub fn bytes_for(self, length: usize) -> usize
The bytes a length: in this format’s unit stands for.
Sourcepub fn layout_for(format: Option<Self>) -> Layout
pub fn layout_for(format: Option<Self>) -> Layout
The shape a reveal step gives from its definition: its format, or
the default.
Sourcepub fn read_row(
self,
text: &str,
row: usize,
more: bool,
) -> Result<TypedRow, String>
pub fn read_row( self, text: &str, row: usize, more: bool, ) -> Result<TypedRow, String>
One row as typed, checked on its own: the characters it should be,
and the repair it took, in words. row is its number from 1, and
more says rows are known to follow it.
Every row but the last is full, since a row’s place in the value is its position: a short row is the last one, and one with rows after it is a row with characters missing.
use rite_model::RevealFormat;
let row = RevealFormat::Paper32.read_row("E9MQ 8S8P H8B", 1, false).unwrap();
assert_eq!(row.text.as_str(), "E9MQ8S8PH8B");
assert!(!row.full);
// A short row where more are to come has characters missing.
assert!(RevealFormat::Paper32.read_row("E9MQ8S8PH8B", 1, true).is_err());§Errors
What is wrong with the row, in words, for the person to fix.
Sourcepub fn decode(self, text: &str) -> Result<TypedValue, String>
pub fn decode(self, text: &str) -> Result<TypedValue, String>
A whole value as typed, rows one after another: its bytes, and the repairs it took, in words.
§Errors
What is wrong with the text, in words.
Sourcepub fn characters(self, bytes: usize) -> usize
pub fn characters(self, bytes: usize) -> usize
Characters a value of bytes bytes takes, parity included.
Trait Implementations§
Source§impl Clone for RevealFormat
impl Clone for RevealFormat
impl Copy for RevealFormat
Source§impl Debug for RevealFormat
impl Debug for RevealFormat
Source§impl<'de> Deserialize<'de> for RevealFormat
impl<'de> Deserialize<'de> for RevealFormat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for RevealFormat
impl Display for RevealFormat
impl Eq for RevealFormat
Source§impl FromStr for RevealFormat
impl FromStr for RevealFormat
Source§impl PartialEq for RevealFormat
impl PartialEq for RevealFormat
Source§impl Serialize for RevealFormat
impl Serialize for RevealFormat
impl StructuralPartialEq for RevealFormat
Auto Trait Implementations§
impl Freeze for RevealFormat
impl RefUnwindSafe for RevealFormat
impl Send for RevealFormat
impl Sync for RevealFormat
impl Unpin for RevealFormat
impl UnsafeUnpin for RevealFormat
impl UnwindSafe for RevealFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.