Skip to main content

WafMap

Struct WafMap 

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

The WAF object representation of a value of type WafObjectType::Map

Implementations§

Source§

impl WafMap

Source

pub fn is_valid(&self) -> bool

Returns true if this WafMap is indeed WafObjectType::Map.

Source

pub fn as_object(&self) -> &WafObject

Returns a reference to this value as a WafObject.

Source

pub fn new(nb_entries: u16) -> Self

Creates a new WafMap with the provided size. All values in the map are initialized to an invalid WafObject instance with a blank key.

§Panics

Panics if memory allocation fails (out of memory).

Source

pub const fn len(&self) -> u16

Returns the length of this WafMap.

Source

pub const fn is_empty(&self) -> bool

Returns true if this WafMap is empty.

Source

pub const fn capacity(&self) -> u16

Returns the capacity of this WafMap.

The capacity is an implementation detail and is only used to for properly deallocating the memory when the map is dropped.

Source

pub fn truncate(&mut self, new_size: u16)

Truncates this WafMap to the provided size.

Has no effect is the current length is not greater than the new size.

It does not free the extra memory, except insofar as it drops the extra elements. Useful when you pessimistically allocate a larger map, but later discover that you don’t need all the capacity.

Source

pub fn iter(&self) -> impl Iterator<Item = &Keyed<WafObject>>

Returns an iterator over the Keyed<WafObject>s in this WafMap.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Keyed<WafObject>>

Returns a mutable iterator over the Keyed<WafObject>s in this WafMap.

Source

pub fn get(&self, key: impl AsRef<ddwaf_object>) -> Option<&Keyed<WafObject>>

Returns a reference to the Keyed<WafObject> with the provided key, if one exists.

If multiple such objects exist in the receiver, the first match is returned.

Source

pub fn get_bstr(&self, key: &[u8]) -> Option<&Keyed<WafObject>>

Returns a reference to the Keyed<WafObject> with the provided key, if one exists.

If multiple such objects exist in the receiver, the first match is returned.

Source

pub fn get_mut(&mut self, key: &[u8]) -> Option<&mut Keyed<WafObject>>

Returns a mutable reference to the Keyed<WafObject> with the provided key, if one exists.

If multiple such objects exist in the receiver, the first match is returned.

Source

pub fn get_str(&self, key: &str) -> Option<&Keyed<WafObject>>

Returns a reference to the Keyed<WafObject> with the provided key, if one exists.

Source

pub fn get_str_mut(&mut self, key: &str) -> Option<&mut Keyed<WafObject>>

Returns a mutable reference to the Keyed<WafObject> with the provided key, if one exists.

Trait Implementations§

Source§

impl AsMut<[Keyed<WafObject>]> for WafMap

Source§

fn as_mut(&mut self) -> &mut [Keyed<WafObject>]

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

impl AsRef<[Keyed<WafObject>]> for WafMap

Source§

fn as_ref(&self) -> &[Keyed<WafObject>]

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

impl AsRef<_ddwaf_object> for WafMap

Source§

fn as_ref(&self) -> &ddwaf_object

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

impl Clone for WafMap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WafMap

Source§

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

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

impl Default for WafMap

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for WafMap

Source§

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

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

impl Drop for WafMap

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<K, V> From<&mut [(K, V)]> for WafMap

Source§

fn from(value: &mut [(K, V)]) -> Self

Converts to this type from the input type.
Source§

impl<K: AsRef<[u8]>, V: Into<WafObject>, const N: usize> From<[(K, V); N]> for WafMap

Source§

fn from(vals: [(K, V); N]) -> Self

Converts to this type from the input type.
Source§

impl<V: Into<WafObject>, const N: usize> From<[(WafObject, V); N]> for WafMap

Source§

fn from(vals: [(WafObject, V); N]) -> Self

Converts to this type from the input type.
Source§

impl Index<usize> for WafMap

Source§

type Output = Keyed<WafObject>

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for WafMap

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IntoIterator for WafMap

Source§

type Item = Keyed<WafObject>

The type of the elements being iterated over.
Source§

type IntoIter = WafIter<<WafMap as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

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

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 WafMap

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 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 TypedWafObject for WafMap

Source§

const TYPE: WafObjectType = WafObjectType::Map

The associated WafObjectType constant corresponding to the typed object’s type discriminator.

Auto Trait Implementations§

§

impl Freeze for WafMap

§

impl RefUnwindSafe for WafMap

§

impl Send for WafMap

§

impl Sync for WafMap

§

impl Unpin for WafMap

§

impl UnwindSafe for WafMap

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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>,