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 a pointer to the string

Return the length of the string, excluding the terminating null. For safety, we limit to 128.

Return true if the string is empty

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.

Fail if the last byte is not zero.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Allow threads to share Strn, since it is static.

Allow threads to share Strn, since it is static.

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

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.