pub enum OptionValue {
Bool(bool),
U32(u32),
I32(i32),
F32(f32),
String(String),
}Expand description
Coerced value handed to a codec’s apply method. Codec code
chooses the appropriate as_* accessor based on the field name.
Variants§
Bool(bool)
A coerced boolean value.
U32(u32)
A coerced unsigned 32-bit integer.
I32(i32)
A coerced signed 32-bit integer.
F32(f32)
A coerced 32-bit float.
String(String)
A string value (also used for OptionKind::Enum matches).
Implementations§
Source§impl OptionValue
impl OptionValue
Sourcepub fn as_bool(&self) -> Result<bool>
pub fn as_bool(&self) -> Result<bool>
Extract the boolean, or Error::InvalidData when the value is
a different kind.
Sourcepub fn as_u32(&self) -> Result<u32>
pub fn as_u32(&self) -> Result<u32>
Extract the u32, or Error::InvalidData when the value is a
different kind.
Sourcepub fn as_i32(&self) -> Result<i32>
pub fn as_i32(&self) -> Result<i32>
Extract the i32, or Error::InvalidData when the value is a
different kind.
Sourcepub fn as_f32(&self) -> Result<f32>
pub fn as_f32(&self) -> Result<f32>
Extract the f32, or Error::InvalidData when the value is a
different kind.
Sourcepub fn as_str(&self) -> Result<&str>
pub fn as_str(&self) -> Result<&str>
Extract the string (also the shape of Enum matches), or
Error::InvalidData when the value is a different kind.
Trait Implementations§
Source§impl Clone for OptionValue
impl Clone for OptionValue
Source§fn clone(&self) -> OptionValue
fn clone(&self) -> OptionValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OptionValue
impl RefUnwindSafe for OptionValue
impl Send for OptionValue
impl Sync for OptionValue
impl Unpin for OptionValue
impl UnsafeUnpin for OptionValue
impl UnwindSafe for OptionValue
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
Mutably borrows from an owned value. Read more