An owned, C-compatible, nul-terminated string, analogous to Rust's CString.
More...
|
| auto | as_ref () const -> ref< CStr > |
| | Returns a borrowed reference to the inner CStr.
|
| |
| auto | into_bytes () -> Vec< u8 > |
| | Consumes the CString and returns the underlying byte vector without the nul terminator.
|
| |
| auto | to_bytes () const -> slice< u8 > |
| | Returns the contents as a byte slice, not including the nul terminator.
|
| |
| auto | to_bytes_with_nul () const -> slice< u8 > |
| | Returns the contents as a byte slice, including the nul terminator.
|
| |
|
| static auto | from_vec_unchecked (Vec< u8 > &&v) -> Self |
| | Creates a CString from a byte vector without checking for interior nul bytes.
|
| |
| template<Impled< Into< Vec< u8 > > > T> |
| static auto | make (T t) -> Result< CString, NulError > |
| | Creates a new CString from a type convertible to Vec<u8>, checking for interior nul bytes.
|
| |
| static auto | from_raw_parts (char const *p) -> CString |
| | Creates a CString by copying from a nul-terminated C string pointer.
|
| |
An owned, C-compatible, nul-terminated string, analogous to Rust's CString.
◆ as_ref()
| auto alloc::ffi::CString::as_ref |
( |
| ) |
const -> ref<CStr> |
|
inline |
Returns a borrowed reference to the inner CStr.
- Returns
- A
ref<CStr> view of the C string data.
◆ from_raw_parts()
| static auto alloc::ffi::CString::from_raw_parts |
( |
char const * | p | ) |
-> CString |
|
inlinestatic |
Creates a CString by copying from a nul-terminated C string pointer.
- Parameters
-
| p | A pointer to a nul-terminated C string. |
- Returns
- A
CString owning a copy of the data.
◆ from_vec_unchecked()
| static auto alloc::ffi::CString::from_vec_unchecked |
( |
Vec< u8 > && | v | ) |
-> Self |
|
inlinestatic |
Creates a CString from a byte vector without checking for interior nul bytes.
- Parameters
-
| v | The byte vector; a nul terminator will be appended. |
- Returns
- A
CString wrapping the data.
◆ into_bytes()
| auto alloc::ffi::CString::into_bytes |
( |
| ) |
-> Vec<u8> |
|
inline |
Consumes the CString and returns the underlying byte vector without the nul terminator.
- Returns
- A
Vec<u8> containing the string bytes.
◆ make()
template<Impled<
Into< Vec< u8 > > > T>
| static auto alloc::ffi::CString::make |
( |
T | t | ) |
-> Result<CString, NulError> |
|
inlinestatic |
Creates a new CString from a type convertible to Vec<u8>, checking for interior nul bytes.
- Template Parameters
-
| T | A type that implements Into<Vec<u8>>. |
- Parameters
-
- Returns
Ok(CString) on success, or Err(NulError) if an interior nul byte is found.
◆ to_bytes()
| auto alloc::ffi::CString::to_bytes |
( |
| ) |
const -> slice<u8> |
|
inline |
Returns the contents as a byte slice, not including the nul terminator.
- Returns
- A
slice<u8> of the string bytes.
◆ to_bytes_with_nul()
| auto alloc::ffi::CString::to_bytes_with_nul |
( |
| ) |
const -> slice<u8> |
|
inline |
Returns the contents as a byte slice, including the nul terminator.
- Returns
- A
slice<u8> of the string bytes with the trailing nul.
The documentation for this class was generated from the following file:
- /home/runner/work/rstd/rstd/src/alloc/ffi/c_str.cppm