[][src]Struct null_terminated::NulStr

#[repr(transparent)]
pub struct NulStr(_);

Null-terminated UTF-8 encoded string

&NulStr is a thin pointer, so it can be readily used with FFI.

One can convert from &Nul<u8> to &NulStr with try_from, which checks whether its argument is valid UTF-8.

Methods

impl NulStr[src]

pub const unsafe fn new_unchecked(p: *const u8) -> &'static Self[src]

Create a reference to a null-terminated string, given a pointer to its start.

The caller must make sure the argument does, in fact, point to a null-terminated string; the string is valid UTF-8; and the returned reference not live longer than the array it refers to. These requirements are not checked.

pub unsafe fn new_unchecked_mut(p: *mut u8) -> &'static mut Self[src]

Create a mutable reference to a null-terminated string, given a pointer to its start.

The caller must make sure the argument does, in fact, point to a null-terminated string; the string is valid UTF-8; and the returned reference not live longer than the array it refers to. These requirements are not checked.

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

Return a slice of the UTF-8 code bytes of the string.

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

Return a mutable slice of the UTF-8 code bytes of the string.

pub fn as_ptr(&self) -> *const u8[src]

Return a pointer to the start of the string.

pub fn as_mut_ptr(&mut self) -> *const u8[src]

Return a mutable pointer to the start of the string.

Important traits for Chars<'a>
pub fn chars(&self) -> Chars[src]

Iterate over the characters of the string.

Important traits for CharIndices<'a>
pub fn char_indices(&self) -> CharIndices[src]

Iterate over the characters of the string and their byte positions.

pub fn is_char_boundary(&self, k: usize) -> bool[src]

Return whether the given byte position is a character boundary.

Trait Implementations

impl Debug for NulStr[src]

impl Display for NulStr[src]

impl PartialEq<NulStr> for NulStr[src]

impl Eq for NulStr[src]

impl Ord for NulStr[src]

impl PartialOrd<NulStr> for NulStr[src]

impl<'a> TryFrom<&'a Nul<u8>> for &'a NulStr[src]

type Error = Utf8Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a mut Nul<u8>> for &'a mut NulStr[src]

type Error = Utf8Error

The type returned in the event of a conversion error.

impl Index<RangeFull> for NulStr[src]

type Output = str

The returned type after indexing.

impl IndexMut<RangeFull> for NulStr[src]

impl Hash for NulStr[src]

impl StructuralPartialEq for NulStr[src]

impl StructuralEq for NulStr[src]

Auto Trait Implementations

impl !Unpin for NulStr

impl Send for NulStr

impl Sync for NulStr

Blanket Implementations

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]