Struct c_utf8::CUtf8Buf[][src]

pub struct CUtf8Buf(_);

An owned, mutable UTF-8 encoded C string (akin to String or PathBuf).

Examples

This type retains certain behaviors that are expected from String such as calling .collect() on iterators.

use c_utf8::CUtf8Buf;

let strings = vec![
    "Hello ",
    "there, ",
    "fellow ",
    "human!"
];

let joined = strings.into_iter().collect::<CUtf8Buf>();
let bytes  = joined.as_bytes_with_nul();

assert_eq!(bytes, b"Hello there, fellow human!\0");

Methods

impl CUtf8Buf
[src]

Creates a new empty CUtf8Buf.

Creates a new C string from a UTF-8 string, appending a nul terminator if one doesn't already exist.

Creates a new C string from a native Rust string without checking for a nul terminator.

Appends a given string slice onto the end of this CUtf8Buf.

Appends the given char to the end of this CUtf8Buf.

Converts self into a native UTF-8 encoded Rust String.

Important traits for Vec<u8>

Converts self into its underlying bytes.

Methods from Deref<Target = CUtf8>

Returns the number of bytes without taking into account the trailing nul byte.

This behavior is the same as that of str::len where the length is not measured in chars.

Examples

Basic usage:

let s = c_utf8!("Hey");

assert_eq!(s.len(), 3);

Returns true if self contains 0 bytes, disregarding the trailing nul byte.

Examples

Basic usage:

let s = c_utf8::CUtf8::EMPTY;

assert!(s.is_empty());
assert_eq!(s.len(), 0);

Returns a pointer to the start of the raw C string.

Returns self as a normal C string.

Returns self as a normal UTF-8 encoded string.

Returns self as a UTF-8 encoded string with a trailing 0 byte.

Important traits for &'a [u8]

Returns the bytes of self without a trailing 0 byte.

Important traits for &'a [u8]

Returns the bytes of self with a trailing 0 byte.

Trait Implementations

impl Clone for CUtf8Buf
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for CUtf8Buf
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for CUtf8Buf
[src]

impl Hash for CUtf8Buf
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialOrd for CUtf8Buf
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for CUtf8Buf
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl PartialEq<CUtf8> for CUtf8Buf
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialEq<CUtf8Buf> for CUtf8
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Default for CUtf8Buf
[src]

Returns the "default value" for a type. Read more

impl Deref for CUtf8Buf
[src]

The resulting type after dereferencing.

Dereferences the value.

impl DerefMut for CUtf8Buf
[src]

Mutably dereferences the value.

impl<T> FromIterator<T> for CUtf8Buf where
    String: FromIterator<T>, 
[src]

Creates a value from an iterator. Read more

impl Debug for CUtf8Buf
[src]

Formats the value using the given formatter. Read more

impl Display for CUtf8Buf
[src]

Formats the value using the given formatter. Read more

impl Write for CUtf8Buf
[src]

Writes a slice of bytes into this writer, returning whether the write succeeded. Read more

Writes a [char] into this writer, returning whether the write succeeded. Read more

Glue for usage of the [write!] macro with implementors of this trait. Read more

impl Borrow<CUtf8> for CUtf8Buf
[src]

Immutably borrows from an owned value. Read more

impl BorrowMut<CUtf8> for CUtf8Buf
[src]

Mutably borrows from an owned value. Read more

impl AsRef<CUtf8> for CUtf8Buf
[src]

Performs the conversion.

impl AsMut<CUtf8> for CUtf8Buf
[src]

Performs the conversion.

impl<'a> From<&'a CUtf8> for CUtf8Buf
[src]

Performs the conversion.

impl<'a> From<&'a mut CUtf8> for CUtf8Buf
[src]

Performs the conversion.

impl From<String> for CUtf8Buf
[src]

Performs the conversion.

impl<'a> From<&'a str> for CUtf8Buf
[src]

Performs the conversion.

impl<'a> From<&'a mut str> for CUtf8Buf
[src]

Performs the conversion.

impl From<Box<CUtf8>> for CUtf8Buf
[src]

Performs the conversion.

impl From<CUtf8Buf> for Box<CUtf8>
[src]

Important traits for Box<R>

Performs the conversion.

impl From<CUtf8Buf> for String
[src]

Performs the conversion.

impl From<CUtf8Buf> for Vec<u8>
[src]

Important traits for Vec<u8>

Performs the conversion.

Auto Trait Implementations

impl Send for CUtf8Buf

impl Sync for CUtf8Buf