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
sourcepub fn to_string(&self) -> String
Available on crate feature alloc
only.
pub fn to_string(&self) -> String
alloc
only.Poor-man’s specialization of ToString::to_string()
pub fn to_owned(self: char_p_ref<'lt>) -> char_p_boxed
Available 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 moresourceimpl 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>
Available on crate feature std
only.
impl<'lt> From<&'lt CStr> for char_p_ref<'lt>
Available 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>
Converts to this type from the input type.
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
Converts to this type from the input type.
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>
impl Send for char_p_ref<'_>where
for<'lt> &'lt [u8]: Send,
impl Sync for char_p_ref<'_>where
for<'lt> &'lt [u8]: Sync,
Auto Trait Implementations
impl<'lt> RefUnwindSafe 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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> CompatExt for T
impl<T> CompatExt for T
sourceimpl<T> ConcreteReprC for Twhere
<T as ReprC>::CLayout: CType<OPAQUE_KIND = Concrete>,
T: ReprC + ?Sized,
impl<T> ConcreteReprC for Twhere
<T as ReprC>::CLayout: CType<OPAQUE_KIND = Concrete>,
T: ReprC + ?Sized,
type ConcreteCLayout = <T as ReprC>::CLayout
sourceimpl<T> FitForCBox for T
impl<T> FitForCBox for T
type CBoxWrapped = Box_<T>
type CBoxWrapped = Box_<T>
Available on crate feature
alloc
only.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> UpcastAny for Twhere
T: 'static,
impl<T> UpcastAny for Twhere
T: 'static,
sourcefn upcast_any(&self) -> &(dyn Any + 'static)
fn upcast_any(&self) -> &(dyn Any + 'static)
Available on crate feature
headers
only.