WafObject

Struct WafObject 

Source
pub struct WafObject { /* private fields */ }
Expand description

The low-level representation of an arbitrary WAF object.

It is usually converted to a TypedWafObject by calling WafObject::as_type.

Implementations§

Source§

impl WafObject

Source

pub fn from_json(json: impl AsRef<[u8]>) -> Option<WafOwned<Self>>

Creates a new WafObject from a JSON string.

This function is not intended to be used with un-trusted/adversarial input. The typical use-case is to facilitate parsing rulesets for use with crate::builder::Builder::add_or_update_config.

§Returns

Returns None if parsing the JSON string into a WafObject was not possible, or if the input JSON string is larger than u32::MAX bytes.

Source

pub fn get_type(&self) -> WafObjectType

Returns the WafObjectType of the underlying value.

Returns WafObjectType::Invalid if the underlying value’s type is not set to a known, valid WafObjectType value.

Source

pub fn as_type<T: TypedWafObject>(&self) -> Option<&T>

Returns a reference to this value as a T if its type corresponds.

Source

pub fn as_type_mut<T: TypedWafObject>(&mut self) -> Option<&mut T>

Returns a mutable reference to this value as a T if its type corresponds.

Source

pub fn is_valid(&self) -> bool

Returns true if this WafObject is not WafObjectType::Invalid, meaning it can be converted to one of the TypedWafObject implementations.

Source

pub fn to_u64(&self) -> Option<u64>

Returns the value of this WafObject as a u64 if its type is WafObjectType::Unsigned.

Source

pub fn to_i64(&self) -> Option<i64>

Returns the value of this WafObject as a i64 if its type is WafObjectType::Signed (or WafObjectType::Unsigned with a value that can be represented as an i64).

Source

pub fn to_f64(&self) -> Option<f64>

Returns the value of this WafObject as a f64 if its type is WafObjectType::Float.

Source

pub fn to_bool(&self) -> Option<bool>

Returns the value of this WafObject as a bool if its type is WafObjectType::Bool.

Source

pub fn to_str(&self) -> Option<&str>

Returns the value of this WafObject as a &str if its type is WafObjectType::String, and the value is valid UTF-8.

Trait Implementations§

Source§

impl AsRef<_ddwaf_object> for WafObject

Source§

fn as_ref(&self) -> &ddwaf_object

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for WafObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WafObject

Source§

fn default() -> WafObject

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for WafObject

Source§

fn deserialize<D>(deserializer: D) -> Result<WafObject, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Drop for WafObject

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<&[u8]> for WafObject

Source§

fn from(value: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for WafObject

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for WafObject

Source§

fn from((): ()) -> Self

Converts to this type from the input type.
Source§

impl<T: TypedWafObject> From<T> for WafObject

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for WafObject

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for WafObject

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for WafObject

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for WafObject

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for WafObject

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for WafObject

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl<T: AsRef<ddwaf_object>> PartialEq<T> for WafObject

Source§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for WafObject

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<WafObject> for WafArray

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafBool

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafFloat

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafInvalid

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafMap

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafNull

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafSigned

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafString

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WafObject> for WafUnsigned

Source§

type Error = ObjectTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(obj: WafObject) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,