Struct terminated::NulTerminatedStr [] [src]

pub struct NulTerminatedStr(_);

A valid UTF8 string terminated by NUL, the null character.

NulTerminatedStr dereferences to a str slice excluding the NUL terminator, meaning all of str's methods are available:

let s = ntstr!("Hello, World!");
assert_eq!(s.len(), 13);
assert!(s.starts_with("Hello"));
assert!(s.ends_with("World!"));
assert_eq!(s.find("World"), Some(7));

Methods

impl NulTerminatedStr
[src]

Creates a NulTerminatedStr from a given string that is NUL-terminated.

If the given string is not correctly NUL-terminated, a NulError is returned.

Example

let mut s = "Hello, World!".to_string();
s.push('\0');

let nts = NulTerminatedStr::from_str_with_nul(&s);
assert!(nts.is_ok());

Returns the content of self including the NUL terminator.

Trait Implementations

impl Deref for NulTerminatedStr
[src]

The resulting type after dereferencing

The method called to dereference a value

impl AsRef<str> for NulTerminatedStr
[src]

Performs the conversion.

impl Debug for NulTerminatedStr
[src]

Formats the value using the given formatter.

impl Display for NulTerminatedStr
[src]

Formats the value using the given formatter. Read more