#[non_exhaustive]pub enum Format {
Text,
Digits,
Alphanumeric,
Hex,
Base64,
Paper32,
Bip39,
}Expand description
What kind of value a person types.
Each format has one canonical representation, which is what an entry step
keeps: the text as typed for a text format, the decoded bytes for an
encoding. An encoding is forgiving of the grouping a person types it in,
so whitespace is dropped before decoding, except between the words of a
bip39 phrase, where it separates them.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Text
Anything the person can type.
Digits
0 to 9.
Alphanumeric
ASCII letters and digits.
Hex
Bytes as hexadecimal, in either case, two digits per byte.
Base64
Bytes as standard base64 with padding, as openssl base64 writes it.
Paper32
Bytes as paper32 rows, as reveal shows them and a sheet holds
them; typed a row at a time, a wrong character in a row corrected.
See crate::paper32.
Bip39
A BIP-39 recovery phrase in the English list, typed a word at a
time; the value is the entropy it encodes, and a length counts
words. See crate::bip39.
Implementations§
Source§impl Format
impl Format
Sourcepub fn is_encoding(self) -> bool
pub fn is_encoding(self) -> bool
Whether the value stands for bytes, which is what the step then keeps.
Sourcepub fn rows(self) -> Option<RevealFormat>
pub fn rows(self) -> Option<RevealFormat>
The encoding a value in this format is typed in a row at a time,
from a sheet or a device’s screen; None for a value typed on one
line. Such a value is a secret, and only enter_secret takes it.
Sourcepub fn length_of(self, bytes: usize) -> usize
pub fn length_of(self, bytes: usize) -> usize
A decoded value of bytes bytes in the format’s unit: the words of
a phrase for bip39, the bytes for another encoding.
Sourcepub fn decode(self, value: &str) -> Result<Vec<u8>, String>
pub fn decode(self, value: &str) -> Result<Vec<u8>, String>
Decode a typed value of an encoding.
§Errors
Returns why the value is not this encoding, or that the format is not one, worded for the person who typed it and naming nothing of what they typed.
Sourcepub fn describe(self) -> &'static str
pub fn describe(self) -> &'static str
The unit a length counts, as a person reads it in a hint.
Sourcepub fn placeholder(self, length: usize) -> Option<String>
pub fn placeholder(self, length: usize) -> Option<String>
A stand-in of length units that satisfies the format, for a run
with no one at the keyboard. Never a real value.
None above PLACEHOLDER_LIMIT: a length a ceremony declares is
not bounded, and a stand-in that size would be allocated for nothing.
The caller then declines to answer rather than answering with
something the rule refuses, which would be asked again without end.
Trait Implementations§
impl Copy for Format
Source§impl<'de> Deserialize<'de> for Format
impl<'de> Deserialize<'de> for Format
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>,
impl Eq for Format
impl StructuralPartialEq for Format
Auto Trait Implementations§
impl Freeze for Format
impl RefUnwindSafe for Format
impl Send for Format
impl Sync for Format
impl Unpin for Format
impl UnsafeUnpin for Format
impl UnwindSafe for Format
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.