#[repr(C)]pub struct StbStringRef {
pub ptr: *const c_char,
pub len: usize,
}Expand description
A borrowed, non-owning view of a string passed as an input to an FFI call. The callee MUST NOT free it and MUST NOT retain it past the call.
Built from a &str on the calling side; the buffer is valid for the
duration of the call (the caller’s borrow).
Fields§
§ptr: *const c_charUTF-8 bytes (valid for the call; NUL-terminated not required).
len: usizeByte length.
Implementations§
Source§impl StbStringRef
impl StbStringRef
Sourcepub fn from_str(s: &str) -> Self
pub fn from_str(s: &str) -> Self
Borrow a &str for the duration of a call. The caller must outlive the
call (normal borrow rules).
Sourcepub unsafe fn as_str<'a>(&self) -> &'a str
pub unsafe fn as_str<'a>(&self) -> &'a str
Read into a safe &str for the callee’s lifetime 'a.
Panics on invalid UTF-8; SDK callback trampolines contain that panic.
§Safety
The caller guarantees ptr is valid for len initialized bytes in a
single allocation, with len <= isize::MAX, and those bytes remain live
and unchanged for the borrow’s lifetime 'a.
Trait Implementations§
Source§impl Clone for StbStringRef
impl Clone for StbStringRef
impl Copy for StbStringRef
impl Send for StbStringRef
impl Sync for StbStringRef
Auto Trait Implementations§
impl Freeze for StbStringRef
impl RefUnwindSafe for StbStringRef
impl Unpin for StbStringRef
impl UnsafeUnpin for StbStringRef
impl UnwindSafe for StbStringRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more