pub struct NgxString<A>(/* private fields */)
where
A: Allocator + Clone;
Expand description
Owned byte string type with Allocator support.
Inspired by bstr and unstable feature(bstr), with two important differences:
- Allocator always have to be specified,
- any allocating methods are failible and require explicit handling of the result.
Implementations§
Source§impl<A> NgxString<A>
impl<A> NgxString<A>
Sourcepub fn new_in(alloc: A) -> Self
pub fn new_in(alloc: A) -> Self
Constructs a new, empty NgxString<A>
.
No allocations will be made until data is added to the string.
Sourcepub fn try_from_bytes_in(
bytes: impl AsRef<[u8]>,
alloc: A,
) -> Result<Self, TryReserveError>
pub fn try_from_bytes_in( bytes: impl AsRef<[u8]>, alloc: A, ) -> Result<Self, TryReserveError>
Tries to construct a new NgxString<A>
from a byte slice.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if this NgxString
has a length of zero, and false
otherwise.
Sourcepub fn append_within_capacity(
&mut self,
other: impl AsRef<[u8]>,
) -> Result<(), usize>
pub fn append_within_capacity( &mut self, other: impl AsRef<[u8]>, ) -> Result<(), usize>
Appends bytes if there is sufficient spare capacity.
Returns the number of remaining bytes on overflow.
Sourcepub fn try_append(
&mut self,
other: impl AsRef<[u8]>,
) -> Result<(), TryReserveError>
pub fn try_append( &mut self, other: impl AsRef<[u8]>, ) -> Result<(), TryReserveError>
Tries to append the bytes to the NgxString
.
Sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more bytes.
Sourcepub fn try_reserve_exact(
&mut self,
additional: usize,
) -> Result<(), TryReserveError>
pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError>
Tries to reserve the minimum capacity for at least additional
more bytes.
Methods from Deref<Target = NgxStr>§
Trait Implementations§
Source§impl<A> Ord for NgxString<A>
impl<A> Ord for NgxString<A>
Source§impl<'a, A: Allocator + Clone> PartialOrd<&'a [u8]> for NgxString<A>
impl<'a, A: Allocator + Clone> PartialOrd<&'a [u8]> for NgxString<A>
Source§impl<'a, A: Allocator + Clone, const N: usize> PartialOrd<&'a [u8; N]> for NgxString<A>
impl<'a, A: Allocator + Clone, const N: usize> PartialOrd<&'a [u8; N]> for NgxString<A>
Source§impl<'a, A: Allocator + Clone> PartialOrd<&'a NgxStr> for NgxString<A>
impl<'a, A: Allocator + Clone> PartialOrd<&'a NgxStr> for NgxString<A>
Source§impl<'a, A: Allocator + Clone> PartialOrd<NgxString<A>> for &'a [u8]
impl<'a, A: Allocator + Clone> PartialOrd<NgxString<A>> for &'a [u8]
Source§impl<'a, A: Allocator + Clone, const N: usize> PartialOrd<NgxString<A>> for &'a [u8; N]
impl<'a, A: Allocator + Clone, const N: usize> PartialOrd<NgxString<A>> for &'a [u8; N]
Source§impl<'a, A: Allocator + Clone> PartialOrd<NgxString<A>> for &'a NgxStr
impl<'a, A: Allocator + Clone> PartialOrd<NgxString<A>> for &'a NgxStr
Source§impl<'a, A: Allocator + Clone> PartialOrd<NgxString<A>> for ngx_str_t
impl<'a, A: Allocator + Clone> PartialOrd<NgxString<A>> for ngx_str_t
Source§impl<A1, A2> PartialOrd<NgxString<A2>> for NgxString<A1>
impl<A1, A2> PartialOrd<NgxString<A2>> for NgxString<A1>
Source§impl<'a, A: Allocator + Clone> PartialOrd<ngx_str_t> for NgxString<A>
impl<'a, A: Allocator + Clone> PartialOrd<ngx_str_t> for NgxString<A>
Source§impl<A> Write for NgxString<A>
impl<A> Write for NgxString<A>
impl<A> Eq for NgxString<A>
Auto Trait Implementations§
impl<A> Freeze for NgxString<A>where
A: Freeze,
impl<A> RefUnwindSafe for NgxString<A>where
A: RefUnwindSafe,
impl<A> Send for NgxString<A>where
A: Send,
impl<A> Sync for NgxString<A>where
A: Sync,
impl<A> Unpin for NgxString<A>where
A: Unpin,
impl<A> UnwindSafe for NgxString<A>where
A: UnwindSafe,
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