#[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
impl ngx_str_t
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
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.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Returns the contents of this ngx_str_t
as a mutable byte slice.
Sourcepub const fn empty() -> ngx_str_t
pub const fn empty() -> ngx_str_t
Creates an empty ngx_str_t
instance.
This method replaces the ngx_null_string
C macro.
Sourcepub unsafe fn from_bytes(pool: *mut ngx_pool_s, src: &[u8]) -> Option<ngx_str_t>
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.
Sourcepub unsafe fn from_str(pool: *mut ngx_pool_s, data: &str) -> ngx_str_t
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§
impl Copy for ngx_str_t
Auto Trait Implementations§
impl Freeze for ngx_str_t
impl RefUnwindSafe for ngx_str_t
impl !Send for ngx_str_t
impl !Sync for ngx_str_t
impl Unpin for ngx_str_t
impl UnwindSafe for ngx_str_t
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more