pub enum ValueRef<'a> {
String(Cow<'a, str>),
Float(f64),
Int(i64),
Buffer(Cow<'a, [u8]>),
Empty,
Boolean(bool),
List(Cow<'a, [Value]>),
}Expand description
A borrowed parameter value that may be a string, a number, or empty. It is intended to
be paired with the ParamValue trait.
The owned equivalent of this type is Value.
Variants§
String(Cow<'a, str>)
A text value of arbitrary length
Float(f64)
A floating point number
Int(i64)
A integral number
Buffer(Cow<'a, [u8]>)
Arbitrary binary data
Empty
No value specified
Boolean(bool)
A true/false value
List(Cow<'a, [Value]>)
A collection of heterogenous Value
Implementations§
Source§impl<'a> ValueRef<'a>
impl<'a> ValueRef<'a>
Sourcepub fn new(s: &'a str) -> Self
pub fn new(s: &'a str) -> Self
Convert a string value into a precise value type by trying successive types to parse, defaulting to storing the string as-is.
Sourcepub fn coerce_bool(&mut self) -> Result<(), ParamValueParseError>
pub fn coerce_bool(&mut self) -> Result<(), ParamValueParseError>
Store the value as a boolean
Sourcepub fn coerce_f64(&mut self) -> Result<(), ParamValueParseError>
pub fn coerce_f64(&mut self) -> Result<(), ParamValueParseError>
Store the value as a floating point number
Sourcepub fn coerce_i64(&mut self) -> Result<(), ParamValueParseError>
pub fn coerce_i64(&mut self) -> Result<(), ParamValueParseError>
Store the value as an integer
Sourcepub fn coerce_str(&mut self) -> Result<(), ParamValueParseError>
pub fn coerce_str(&mut self) -> Result<(), ParamValueParseError>
Store the value as a string
Sourcepub fn coerce_empty(&mut self)
pub fn coerce_empty(&mut self)
Discard the value, leaving this value ValueRef::Empty
Sourcepub fn coerce_buffer(&mut self) -> Result<(), ParamValueParseError>
pub fn coerce_buffer(&mut self) -> Result<(), ParamValueParseError>
Store the value as a byte buffer
Sourcepub fn coerce_list(&mut self) -> Result<(), ParamValueParseError>
pub fn coerce_list(&mut self) -> Result<(), ParamValueParseError>
Store the value as a list
Trait Implementations§
impl Eq for ValueRef<'_>
Source§impl<U: Into<Value>> FromIterator<U> for ValueRef<'static>
impl<U: Into<Value>> FromIterator<U> for ValueRef<'static>
Source§fn from_iter<T: IntoIterator<Item = U>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = U>>(iter: T) -> Self
Creates a value from an iterator. Read more
Source§impl ParamValue for ValueRef<'_>
impl ParamValue for ValueRef<'_>
Source§fn 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
Source§fn 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.
Source§fn is_boolean(&self) -> bool
fn is_boolean(&self) -> bool
Check if the value is a boolean
Source§fn to_buffer(&self) -> Result<Cow<'_, [u8]>, ParamValueParseError>
fn to_buffer(&self) -> Result<Cow<'_, [u8]>, ParamValueParseError>
Get the value as a byte buffer, if possible. Read more
Source§fn 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 possibleSource§fn as_bytes(&self) -> Cow<'_, [u8]>
fn as_bytes(&self) -> Cow<'_, [u8]>
Convert the value to a byte string, the bytes
of the string representation.
Source§fn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
Check if the value is of either numeric type.
Source§impl<'a> PartialOrd for ValueRef<'a>
impl<'a> PartialOrd for ValueRef<'a>
impl<'a> StructuralPartialEq for ValueRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for ValueRef<'a>
impl<'a> RefUnwindSafe for ValueRef<'a>
impl<'a> Send for ValueRef<'a>
impl<'a> Sync for ValueRef<'a>
impl<'a> Unpin for ValueRef<'a>
impl<'a> UnsafeUnpin for ValueRef<'a>
impl<'a> UnwindSafe for ValueRef<'a>
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