Struct ngx_str_t

Source
#[repr(C)]
pub struct ngx_str_t { pub len: usize, pub data: *mut u8, }

Fields§

§len: usize§data: *mut u8

Implementations§

Source§

impl ngx_str_t

Source

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

Returns the contents of this ngx_str_t as a byte slice.

The returned slice will not contain the optional nul terminator that ngx_str_t.data may have.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the contents of this ngx_str_t as a mutable byte slice.

Source

pub fn is_empty(&self) -> bool

Returns true if the string has a length of 0.

Source

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

Returns the contents of this ngx_str_t a string slice (&str) if the contents are utf-8 encoded.

§Returns

A string slice (&str) representing the nginx string, or else a Utf8Error.

Source

pub const fn empty() -> ngx_str_t

Creates an empty ngx_str_t instance.

This method replaces the ngx_null_string C macro.

Source

pub unsafe fn from_bytes(pool: *mut ngx_pool_s, src: &[u8]) -> Option<ngx_str_t>

Create an ngx_str_t instance from a byte slice.

§Safety

The caller must provide a valid pointer to a memory pool.

Source

pub unsafe fn from_str(pool: *mut ngx_pool_s, data: &str) -> ngx_str_t

Create an ngx_str_t instance from a string slice (&str).

§Arguments
  • pool - A pointer to the nginx memory pool (ngx_pool_t).
  • data - The string slice from which to create the nginx string.
§Safety

This function is marked as unsafe because it accepts a raw pointer argument. There is no way to know if pool is pointing to valid memory. The caller must provide a valid pool to avoid indeterminate behavior.

§Returns

An ngx_str_t instance representing the given string slice.

Source

pub fn split_at(&self, mid: usize) -> Option<(ngx_str_t, ngx_str_t)>

Divides one ngx_str_t into two at an index.

§Safety

The results will reference the original string; be wary of the ownership and lifetime.

Source

pub fn strip_prefix(&self, prefix: impl AsRef<[u8]>) -> Option<ngx_str_t>

Returns an ngx_str_t with the prefix removed.

If the string starts with the byte sequence prefix, returns the substring after the prefix, wrapped in Some. The resulting substring can be empty.

§Safety

The result will reference the original string; be wary of the ownership and lifetime.

The method is not marked as unsafe as everything it does is possible via safe interfaces.

Source

pub fn strip_suffix(&self, suffix: impl AsRef<[u8]>) -> Option<ngx_str_t>

Returns an ngx_str_t with the suffix removed.

If the string ends with the byte sequence suffix, returns the substring before the suffix, wrapped in Some. The resulting substring can be empty.

§Safety

The result will reference the original string; be wary of the ownership and lifetime.

The method is not marked as unsafe as everything it does is possible via safe interfaces.

Trait Implementations§

Source§

impl AsMut<[u8]> for ngx_str_t

Source§

fn as_mut(&mut self) -> &mut [u8]

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

impl AsRef<[u8]> for ngx_str_t

Source§

fn as_ref(&self) -> &[u8]

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

impl Clone for ngx_str_t

Source§

fn clone(&self) -> ngx_str_t

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 ngx_str_t

Source§

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

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

impl Default for ngx_str_t

Source§

fn default() -> ngx_str_t

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

impl Display for ngx_str_t

Source§

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

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

impl From<ngx_str_t> for &[u8]

Source§

fn from(s: ngx_str_t) -> &[u8]

Converts to this type from the input type.
Source§

impl Hash for ngx_str_t

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ngx_str_t

Source§

fn cmp(&self, other: &ngx_str_t) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a> PartialEq<&'a NgxStr> for ngx_str_t

Source§

fn eq(&self, other: &&'a NgxStr) -> 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<'a> PartialEq<NgxStr> for ngx_str_t

Source§

fn eq(&self, other: &NgxStr) -> 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<'a, A: Allocator + Clone> PartialEq<NgxString<A>> for ngx_str_t

Source§

fn eq(&self, other: &NgxString<A>) -> 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<'a> PartialEq<ngx_str_t> for &'a NgxStr

Source§

fn eq(&self, other: &ngx_str_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<'a> PartialEq<ngx_str_t> for NgxStr

Source§

fn eq(&self, other: &ngx_str_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<'a, A: Allocator + Clone> PartialEq<ngx_str_t> for NgxString<A>

Source§

fn eq(&self, other: &ngx_str_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 PartialEq for ngx_str_t

Source§

fn eq(&self, other: &ngx_str_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<'a> PartialOrd<&'a NgxStr> for ngx_str_t

Source§

fn partial_cmp(&self, other: &&'a NgxStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> PartialOrd<NgxStr> for ngx_str_t

Source§

fn partial_cmp(&self, other: &NgxStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, A: Allocator + Clone> PartialOrd<NgxString<A>> for ngx_str_t

Source§

fn partial_cmp(&self, other: &NgxString<A>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> PartialOrd<ngx_str_t> for &'a NgxStr

Source§

fn partial_cmp(&self, other: &ngx_str_t) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> PartialOrd<ngx_str_t> for NgxStr

Source§

fn partial_cmp(&self, other: &ngx_str_t) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, A: Allocator + Clone> PartialOrd<ngx_str_t> for NgxString<A>

Source§

fn partial_cmp(&self, other: &ngx_str_t) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for ngx_str_t

Source§

fn partial_cmp(&self, other: &ngx_str_t) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<ngx_str_t> for &str

Source§

type Error = Utf8Error

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

fn try_from(s: ngx_str_t) -> Result<&str, <&str as TryFrom<ngx_str_t>>::Error>

Performs the conversion.
Source§

impl Copy for ngx_str_t

Source§

impl Eq for ngx_str_t

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.