pub struct ZString { /* private fields */ }
Expand description
Like String, CString for zend_string.
Implementations§
Source§impl ZString
impl ZString
Sourcepub fn new_persistent(s: impl AsRef<[u8]>) -> Self
pub fn new_persistent(s: impl AsRef<[u8]>) -> Self
Creates a new persistent zend string from a container of bytes.
Sourcepub unsafe fn from_raw(ptr: *mut zend_string) -> Self
pub unsafe fn from_raw(ptr: *mut zend_string) -> Self
Create owned object From raw pointer, usually used in pairs with
into_raw
.
§Safety
This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.
Sourcepub fn into_raw(self) -> *mut zend_string
pub fn into_raw(self) -> *mut zend_string
Consumes the ZString and transfers ownership of the string to a raw pointer.
Methods from Deref<Target = ZStr>§
Sourcepub fn as_ptr(&self) -> *const zend_string
pub fn as_ptr(&self) -> *const zend_string
Returns a raw pointer wrapped.
Sourcepub fn as_mut_ptr(&mut self) -> *mut zend_string
pub fn as_mut_ptr(&mut self) -> *mut zend_string
Returns a raw pointer wrapped.
Sourcepub fn as_c_str_ptr(&self) -> *const c_char
pub fn as_c_str_ptr(&self) -> *const c_char
Converts to a raw C string pointer.
Sourcepub fn to_c_str(&self) -> Result<&CStr, FromBytesWithNulError>
pub fn to_c_str(&self) -> Result<&CStr, FromBytesWithNulError>
Extracts a CStr
slice containing the inner C string.
Sourcepub fn to_str(&self) -> Result<&str, Utf8Error>
pub fn to_str(&self) -> Result<&str, Utf8Error>
Yields a str slice if the ZStr
contains valid UTF-8.
Sourcepub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Converts a slice of bytes to a string, including invalid characters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ZString
impl RefUnwindSafe for ZString
impl !Send for ZString
impl !Sync for ZString
impl Unpin for ZString
impl UnwindSafe for ZString
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