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) -> &str

Convert the nginx string to a string slice (&str).

§Panics

This function panics if the ngx_str_t is not valid UTF-8.

§Returns

A string slice (&str) representing the nginx string.

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.

Trait Implementations§

Source§

impl Clone for ngx_str_t

Source§

fn clone(&self) -> ngx_str_t

Returns a copy 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 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

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.