Skip to main content

WafString

Struct WafString 

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

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

Implementations§

Source§

impl WafString

Source

pub fn is_valid(&self) -> bool

Returns true if this WafString is indeed WafObjectType::String.

Source

pub fn as_object(&self) -> &WafObject

Returns a reference to this value as a WafObject.

Source

pub fn new(val: impl AsRef<[u8]>) -> Option<Self>

Creates a new WafString with the provided value. Only returns none if the string is larger than u32::MAX bytes.

§Panics

Panics if memory allocation fails (out of memory).

Source

pub fn new_literal(val: impl Into<&'static [u8]>) -> Self

Creates a new WafString with the provided static value.

§Panics

Panics if the string is larger than u32::MAX bytes.

Source

pub fn len(&self) -> u32

Returns the length of this WafString, in bytes.

Source

pub fn is_empty(&self) -> bool

Returns true if this WafString is empty.

Source

pub fn as_bytes(&self) -> &[u8]

Returns a slice of the bytes from this WafString.

Source

pub fn as_str(&self) -> Result<&str, Utf8Error>

Returns a string slice from this WafString.

§Errors

Returns an error if the underlying data is not a valid UTF-8 string, under the same conditions as std::str::from_utf8.

Trait Implementations§

Source§

impl AsRef<_ddwaf_object> for WafString

Source§

fn as_ref(&self) -> &ddwaf_object

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

impl Clone for WafString

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 WafString

Source§

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

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

impl Default for WafString

Source§

fn default() -> Self

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

impl Drop for WafString

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: AsRef<[u8]>> From<T> for WafString

Source§

fn from(val: T) -> Self

Converts to this type from the input type.
Source§

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

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 WafString

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

Source§

const TYPE: WafObjectType = WafObjectType::String

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

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> 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.