pub trait ParamValue {
Show 22 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 is_list(&self) -> bool;
fn is_boolean(&self) -> bool;
fn to_f64(&self) -> Result<f64, ParamValueParseError>;
fn to_bool(&self) -> Result<bool, ParamValueParseError>;
fn to_i64(&self) -> Result<i64, ParamValueParseError>;
fn to_str(&self) -> Cow<'_, str>;
fn to_buffer(&self) -> Result<Cow<'_, [u8]>, ParamValueParseError>;
fn as_slice(&self) -> Cow<'_, [Value]>;
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 is_boolean(&self) -> bool
fn is_boolean(&self) -> bool
Check if the value is a boolean
Sourcefn to_f64(&self) -> Result<f64, ParamValueParseError>
fn to_f64(&self) -> Result<f64, ParamValueParseError>
Get the value as an f64, if possible
Sourcefn to_bool(&self) -> Result<bool, ParamValueParseError>
fn to_bool(&self) -> Result<bool, ParamValueParseError>
Get the value as a bool, if possible
Sourcefn to_i64(&self) -> Result<i64, ParamValueParseError>
fn to_i64(&self) -> Result<i64, ParamValueParseError>
Get the value as an i64, if possible
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
Provided Methods§
Sourcefn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
Check if the value is of either numeric type.
Sourcefn to_f32(&self) -> Result<f32, ParamValueParseError>
fn to_f32(&self) -> Result<f32, ParamValueParseError>
Get the value as an f32, if possible
Sourcefn to_i32(&self) -> Result<i32, ParamValueParseError>
fn to_i32(&self) -> Result<i32, ParamValueParseError>
Get the value as an i32, if possible
Sourcefn to_u64(&self) -> Result<u64, ParamValueParseError>
fn to_u64(&self) -> Result<u64, ParamValueParseError>
Get the value as an u64, if possible
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".