riot_wrappers::helpers

Trait PointerToCStr

Source
pub(crate) trait PointerToCStr {
    // Required method
    unsafe fn to_lifetimed_cstr<'a>(self) -> Option<&'a CStr>;
}
Expand description

Trait that eases conversions from a char pointer (no matter the signedness, they are used inconsistently in RIOT) to a CStr. The result is often used with ?.to_str().ok()?.

Required Methods§

Source

unsafe fn to_lifetimed_cstr<'a>(self) -> Option<&'a CStr>

Cast self around until it is suitable input to core::ffi::CStr::from_ptr(), and run that function. See there for safety requirements; in particular, the user needs to ensure that the lifetime is suitable.

This returns None if self is the null pointer.

Implementations on Foreign Types§

Source§

impl PointerToCStr for *const i8

Source§

unsafe fn to_lifetimed_cstr<'a>(self) -> Option<&'a CStr>

Source§

impl PointerToCStr for *const u8

Source§

unsafe fn to_lifetimed_cstr<'a>(self) -> Option<&'a CStr>

Implementors§