Struct safer_ffi::char_p::char_p_ref
source · [−]#[repr(transparent)]pub struct char_p_ref<'lt>(_, _);
Expand description
A #[repr(c)]
null-terminated UTF-8 encoded string, for compatibility
with both the C char *
API and Rust’s str
.
This is a borrowed version, i.e., with the semantics of
&'lt CStr
/ &'lt str
, but for it being a slim pointer.
C Layout
Implementations
sourceimpl char_p_ref<'static>
impl char_p_ref<'static>
sourceimpl<'lt> char_p_ref<'lt>
impl<'lt> char_p_ref<'lt>
pub const unsafe fn from_ptr_unchecked(ptr: NonNull<u8>) -> Self
sourceimpl<'lt> char_p_ref<'lt>
impl<'lt> char_p_ref<'lt>
pub fn bytes(self: char_p_ref<'lt>) -> impl Iterator<Item = NonZeroU8> + 'lt
pub fn to_nonzero_bytes(self: char_p_ref<'lt>) -> &'lt [NonZeroU8]
pub fn to_bytes(self: char_p_ref<'lt>) -> &'lt [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn to_bytes_with_null(self: char_p_ref<'lt>) -> &'lt [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn to_str(self: char_p_ref<'lt>) -> &'lt str
pub fn to_str_with_null(self: char_p_ref<'lt>) -> &'lt str
pub fn to_owned(self: char_p_ref<'lt>) -> char_p_boxed
This is supported on crate feature
alloc
only.Trait Implementations
sourceimpl<'lt> Clone for char_p_ref<'lt>
impl<'lt> Clone for char_p_ref<'lt>
sourcefn clone(&self) -> char_p_ref<'lt>
fn clone(&self) -> char_p_ref<'lt>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for char_p_ref<'_>
impl Debug for char_p_ref<'_>
sourceimpl Display for char_p_ref<'_>
impl Display for char_p_ref<'_>
sourceimpl<'lt> From<&'lt CStr> for char_p_ref<'lt>
This is supported on crate feature std
only.
impl<'lt> From<&'lt CStr> for char_p_ref<'lt>
This is supported on crate feature
std
only.Panic
Panics if the CStr
is not valid UTF-8.
sourcefn from(s: &'lt CStr) -> char_p_ref<'lt>
fn from(s: &'lt CStr) -> char_p_ref<'lt>
Performs the conversion.
sourceimpl<'lt> From<char_p_ref<'lt>> for char_p_raw
impl<'lt> From<char_p_ref<'lt>> for char_p_raw
sourcefn from(it: char_p_ref<'lt>) -> char_p_raw
fn from(it: char_p_ref<'lt>) -> char_p_raw
Performs the conversion.
sourceimpl<'lt> PartialEq<char_p_ref<'lt>> for char_p_ref<'lt>
impl<'lt> PartialEq<char_p_ref<'lt>> for char_p_ref<'lt>
sourceimpl<'lt> ReprC for char_p_ref<'lt> where
NonNullRef<c_char>: ReprC,
impl<'lt> ReprC for char_p_ref<'lt> where
NonNullRef<c_char>: ReprC,
sourceimpl<'lt> TryFrom<&'lt str> for char_p_ref<'lt>
impl<'lt> TryFrom<&'lt str> for char_p_ref<'lt>
type Error = InvalidNulTerminator<()>
type Error = InvalidNulTerminator<()>
The type returned in the event of a conversion error.
sourcefn try_from(s: &'lt str) -> Result<char_p_ref<'lt>, InvalidNulTerminator<()>>
fn try_from(s: &'lt str) -> Result<char_p_ref<'lt>, InvalidNulTerminator<()>>
Performs the conversion.
impl<'lt> Copy for char_p_ref<'lt>
impl<'lt> Eq for char_p_ref<'lt>
Auto Trait Implementations
impl<'lt> RefUnwindSafe for char_p_ref<'lt>
impl<'lt> !Send for char_p_ref<'lt>
impl<'lt> !Sync for char_p_ref<'lt>
impl<'lt> Unpin for char_p_ref<'lt>
impl<'lt> UnwindSafe for char_p_ref<'lt>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ManuallyDropMut for T
impl<T> ManuallyDropMut for T
type Ret = ManuallyDrop<T>
fn manually_drop_mut(&'__ mut self) -> &'__ mut ManuallyDrop<T>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more