Struct NgxStr

Source
pub struct NgxStr(/* private fields */);
Expand description

Representation of a borrowed Nginx string.

Implementations§

Source§

impl NgxStr

Source

pub unsafe fn from_ngx_str<'a>(str: ngx_str_t) -> &'a NgxStr

Create an NgxStr from an ngx_str_t.

§Safety

The caller has provided a valid ngx_str_t with a data pointer that points to range of bytes of at least len bytes, whose content remains valid and doesn’t change for the lifetime of the returned NgxStr.

Source

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

Access the NgxStr as a byte slice.

Source

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

Yields a &str slice if the NgxStr contains valid UTF-8.

Source

pub fn to_string_lossy(&self) -> Cow<'_, str>

Converts an NgxStr into a Cow<str>, replacing invalid UTF-8 sequences.

See String::from_utf8_lossy.

Source

pub fn is_empty(&self) -> bool

Returns true if the NgxStr is empty, otherwise false.

Trait Implementations§

Source§

impl AsRef<[u8]> for NgxStr

Source§

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

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

impl Default for &NgxStr

Source§

fn default() -> Self

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

impl From<&[u8]> for &NgxStr

Source§

fn from(bytes: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for &NgxStr

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for NgxStr

§

impl RefUnwindSafe for NgxStr

§

impl Send for NgxStr

§

impl !Sized for NgxStr

§

impl Sync for NgxStr

§

impl Unpin for NgxStr

§

impl UnwindSafe for NgxStr

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