#[non_exhaustive]pub enum Format {
Text,
Digits,
Alphanumeric,
Hex,
Base64,
}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.
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.
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 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.