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]
fn from_str_with_nul(s: &str) -> Result<&NulTerminatedStr, NulError>
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());
fn as_str_with_nul(&self) -> &str
Returns the content of self including the NUL terminator.
Trait Implementations
impl Deref for NulTerminatedStr
[src]
type Target = str
The resulting type after dereferencing
fn deref(&self) -> &str
The method called to dereference a value
impl AsRef<str> for NulTerminatedStr
[src]
fn as_ref(&self) -> &str
Performs the conversion.