Lyricdev
GitHub

struct CStr

pub struct CStr

A C string: the address of bytes a NUL ends, const char * at a C function's boundary.

It is borrowed: the bytes are C's, and they are valid as long as C says. CStr.toString copies them into a string. A C function that may return null returns a ?CStr.

Methods

pub fn length(): int

Returns the number of bytes before the NUL.

pub fn toString(): string throws Utf8Error

Returns a copy of the bytes as a string.

Errors

A Utf8Error where the bytes are no well-formed UTF-8, with the offset of the first that is none.