#[repr(C)]pub struct RbString {
pub len: u32,
pub data: *const u8,
}Expand description
FFI-safe borrowed string reference
This is a view into a UTF-8 string that the caller owns. The string data must remain valid for the duration of the FFI call.
§Memory Layout
+--------+--------+
| len | data |
| (u32) | (*u8) |
+--------+--------+§Invariants
- If
datais non-null, it must point to valid UTF-8 bytes - If
datais non-null, it must be null-terminated (for C compatibility) lenis the byte length, NOT including the null terminator- If
len == 0anddata == null, the string is considered “not present” (None) - If
len == 0anddata != null, the string is an empty string
Fields§
§len: u32Length in bytes (excluding null terminator)
data: *const u8Pointer to null-terminated UTF-8 data
Implementations§
Source§impl RbString
impl RbString
Sourcepub const fn from_static(s: &'static str) -> Self
pub const fn from_static(s: &'static str) -> Self
Create a string from a static str
§Safety
The string must be null-terminated. Use this only with string literals or strings known to have a null terminator.
Sourcepub fn is_present(&self) -> bool
pub fn is_present(&self) -> bool
Check if this string is present (not None)
Trait Implementations§
impl Copy for RbString
impl Send for RbString
impl Sync for RbString
Auto Trait Implementations§
impl Freeze for RbString
impl RefUnwindSafe for RbString
impl Unpin for RbString
impl UnsafeUnpin for RbString
impl UnwindSafe for RbString
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