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§
source§impl char_p_ref<'static>
impl char_p_ref<'static>
source§impl<'lt> char_p_ref<'lt>
impl<'lt> char_p_ref<'lt>
pub const unsafe fn from_ptr_unchecked(ptr: NonNull<u8>) -> Self
source§impl<'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] ⓘ
pub fn to_bytes_with_null(self: char_p_ref<'lt>) -> &'lt [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§
source§impl<'lt> Clone for char_p_ref<'lt>
impl<'lt> Clone for char_p_ref<'lt>
source§fn clone(&self) -> char_p_ref<'lt>
fn clone(&self) -> char_p_ref<'lt>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for char_p_ref<'_>
impl Debug for char_p_ref<'_>
source§impl Display for char_p_ref<'_>
impl Display for char_p_ref<'_>
source§impl<'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.
source§fn 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.
source§impl<'lt> From<char_p_ref<'lt>> for char_p_raw
impl<'lt> From<char_p_ref<'lt>> for char_p_raw
source§fn 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.
source§impl<'lt> PartialEq<char_p_ref<'lt>> for char_p_ref<'lt>
impl<'lt> PartialEq<char_p_ref<'lt>> for char_p_ref<'lt>
source§impl<'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,
source§impl<'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.
source§fn 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§
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
source§impl<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
source§impl<T> FitForCBox for T
impl<T> FitForCBox for T
§type CBoxWrapped = Box_<T>
type CBoxWrapped = Box_<T>
Available on crate feature
alloc
only.source§impl<T> ManuallyDropMut for T
impl<T> ManuallyDropMut for T
type Ret = ManuallyDrop<T>
fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>
source§impl<T> UpcastAny for Twhere
T: 'static,
impl<T> UpcastAny for Twhere T: 'static,
source§fn upcast_any(&self) -> &(dyn Any + 'static)
fn upcast_any(&self) -> &(dyn Any + 'static)
Available on crate feature
headers
only.