Struct kernel::str::CStr[][src]

#[repr(transparent)]
pub struct CStr(_);
Expand description

A string that is guaranteed to have exactly one NUL byte, which is at the end.

Used for interoperability with kernel APIs that take C strings.

Implementations

Returns the length of this string excluding NUL.

Returns the length of this string with NUL.

Returns true if the string only includes NUL.

Wraps a raw C string pointer.

Safety

ptr must be a valid pointer to a NUL-terminated C string, and it must last at least 'a. When CStr is alive, the memory pointed by ptr must not be mutated.

Creates a CStr from a [u8].

The provided slice must be NUL-terminated, does not contain any interior NUL bytes.

Creates a CStr from a [u8] without performing any additional checks.

Safety

bytes must end with a NUL byte, and should only have a single NUL byte (or the string will be truncated).

Returns a C pointer to the string.

Convert the string to a byte slice without the trailing 0 byte.

Convert the string to a byte slice containing the trailing 0 byte.

Trait Implementations

Performs the conversion.

The resulting type after dereferencing.

Dereferences the value.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more