Skip to main content

RevealFormat

Enum RevealFormat 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

pub fn as_str(self) -> &'static str

The name a ceremony writes.

Source

pub fn is_words(self) -> bool

Whether the value is words, one per row, rather than characters.

Source

pub fn unit(self) -> &'static str

What length: counts in this format, as a person reads it.

Source

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.

Source

pub fn bytes_for(self, length: usize) -> usize

The bytes a length: in this format’s unit stands for.

Source

pub fn layout(self) -> Layout

The shape a sheet takes for this encoding.

Source

pub fn layout_for(format: Option<Self>) -> Layout

The shape a reveal step gives from its definition: its format, or the default.

Source

pub fn rows(self, bytes: usize) -> usize

Rows a value of bytes bytes takes.

Source

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.

Source

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.

Source

pub fn characters(self, bytes: usize) -> usize

Characters a value of bytes bytes takes, parity included.

Trait Implementations§

Source§

impl Clone for RevealFormat

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RevealFormat

Source§

impl Debug for RevealFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RevealFormat

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for RevealFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RevealFormat

Source§

impl FromStr for RevealFormat

Source§

type Err = UnknownRevealFormat

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for RevealFormat

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RevealFormat

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RevealFormat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.