Struct bl602_sdk::Strn [−][src]
pub struct Strn<'a> { pub rep: StrnRep<'a>, }
Expand description
Represents a null-terminated string, suitable for passing to C APIs as * const char
.
The string can be a null-terminated byte string created in Rust, or a pointer to a null-terminated string returned by C.
Pointer may be null.
Fields
rep: StrnRep<'a>
Either a byte string terminated with null, or a pointer to a null-terminated string
Implementations
Create a new Strn
with a byte string. Fail if the last byte is not zero.
Strn::new(b"network\0") strn!("network")
Create a new Strn
with a null-terminated string pointer returned by C.
Return the length of the string, excluding the terminating null. For safety, we limit to 128.
Return the byte string as a null-terminated * const char
C-style string.
Fail if the last byte is not zero.
Return the byte string. Fail if the last byte is not zero.
Fail if the last byte is not zero.
Trait Implementations
Allow threads to share Strn, since it is static.
Allow threads to share Strn, since it is static.
Auto Trait Implementations
impl<'a> Unpin for Strn<'a>
Blanket Implementations
pub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
pub fn from(t: T) -> T
pub fn from(t: T) -> T
Performs the conversion.
pub fn into(self) -> U
pub fn into(self) -> U
Performs the conversion.