pub enum ConditionValue {
String(String),
Number(f64),
Boolean(bool),
Array(Vec<String>),
}Expand description
A condition value can be a string, number, boolean, or array of strings
Variants§
Implementations§
Source§impl ConditionValue
impl ConditionValue
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
The variant’s name — what an error says in place of the value, so a request value or a policy value never reaches a log (wami 001).
Sourcepub fn as_string(&self) -> Result<String, ConditionError>
pub fn as_string(&self) -> Result<String, ConditionError>
The value as text: a string, or a number or boolean written out.
§Errors
ConditionError::TypeMismatch for a list.
Sourcepub fn as_number(&self) -> Result<f64, ConditionError>
pub fn as_number(&self) -> Result<f64, ConditionError>
The value as a finite number.
Parse reads a policy’s numbers through this very function, so what it
refuses is refused at parse too. "NaN" and "inf" are refused: they
read as f64, and a comparison with them is never met.
§Errors
ConditionError::TypeMismatch for anything else.
Sourcepub fn as_boolean(&self) -> Result<bool, ConditionError>
pub fn as_boolean(&self) -> Result<bool, ConditionError>
The value as a boolean: true/false, as such or as a string.
§Errors
ConditionError::InvalidBooleanValue for any other string,
ConditionError::TypeMismatch for a number or a list.
Trait Implementations§
Source§impl Clone for ConditionValue
impl Clone for ConditionValue
Source§impl Debug for ConditionValue
impl Debug for ConditionValue
Source§impl From<Value> for ConditionValue
impl From<Value> for ConditionValue
Source§impl PartialEq for ConditionValue
impl PartialEq for ConditionValue
impl StructuralPartialEq for ConditionValue
Auto Trait Implementations§
impl Freeze for ConditionValue
impl RefUnwindSafe for ConditionValue
impl Send for ConditionValue
impl Sync for ConditionValue
impl Unpin for ConditionValue
impl UnsafeUnpin for ConditionValue
impl UnwindSafe for ConditionValue
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