Trait mzdata::params::ParamValue
source · pub trait ParamValue {
Show 18 methods
// Required methods
fn is_empty(&self) -> bool;
fn is_i64(&self) -> bool;
fn is_f64(&self) -> bool;
fn is_buffer(&self) -> bool;
fn is_str(&self) -> bool;
fn to_f64(&self) -> Result<f64, ParamValueParseError>;
fn to_i64(&self) -> Result<i64, ParamValueParseError>;
fn to_str(&self) -> Cow<'_, str>;
fn to_buffer(&self) -> Result<Cow<'_, [u8]>, ParamValueParseError>;
fn parse<T: FromStr>(&self) -> Result<T, T::Err>;
fn as_bytes(&self) -> Cow<'_, [u8]>;
fn as_ref(&self) -> ValueRef<'_>;
fn data_len(&self) -> usize;
// Provided methods
fn is_numeric(&self) -> bool { ... }
fn to_f32(&self) -> Result<f32, ParamValueParseError> { ... }
fn to_i32(&self) -> Result<i32, ParamValueParseError> { ... }
fn to_u64(&self) -> Result<u64, ParamValueParseError> { ... }
fn as_str(&self) -> Cow<'_, str> { ... }
}
Expand description
Access a parameter’s value, with specific coercion rules and eager type conversion.
Required Methods§
sourcefn is_f64(&self) -> bool
fn is_f64(&self) -> bool
Check if the value is a floating point number explicitly. An integral number might still be usable as a floating point number
sourcefn is_str(&self) -> bool
fn is_str(&self) -> bool
Check if the value is stored as an explicit string. All variants can be coerced to a string.
sourcefn to_buffer(&self) -> Result<Cow<'_, [u8]>, ParamValueParseError>
fn to_buffer(&self) -> Result<Cow<'_, [u8]>, ParamValueParseError>
Get the value as a byte buffer, if possible.
The intent here is distinct from ParamValue::as_bytes
. The byte buffer
represents the byte representation of the native value, while
ParamValue::as_bytes
is a byte string of the string representation.
sourcefn parse<T: FromStr>(&self) -> Result<T, T::Err>
fn parse<T: FromStr>(&self) -> Result<T, T::Err>
Convert the value’s string representation to T
if possible
sourcefn as_bytes(&self) -> Cow<'_, [u8]>
fn as_bytes(&self) -> Cow<'_, [u8]>
Convert the value to a byte string, the bytes of the string representation.
fn data_len(&self) -> usize
Provided Methods§
sourcefn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
Check if the value is of either numeric type.
Object Safety§
This trait is not object safe.