Struct safer_ffi::c_char

source ·
#[repr(transparent)]
pub struct c_char(pub u8);
Expand description

A ReprC standalone type with the same layout and ABI as ::libc::c_char.

By standalone, the idea is that this is defined as a (transparent) newtype struct, rather than as a type alias, which is error-prone and yields less-portable headers (since the header generation will resolve the type alias and emit, for instance, int8_t, ⚠️).

By using this type, you guarantee that the C char type be used in the headers.

Tuple Fields§

§0: u8

Trait Implementations§

source§

impl Clone for c_char

source§

fn clone(&self) -> c_char

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for c_char

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for c_char

source§

fn default() -> c_char

Returns the “default value” for a type. Read more
source§

impl Hash for c_char

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl LegacyCType for c_char

source§

fn c_short_name_fmt(fmt: &mut Formatter<'_>) -> Result

A short-name description of the type, mainly used to fill “placeholders” such as when monomorphising generics structs or arrays. Read more
source§

fn c_var_fmt(fmt: &mut Formatter<'_>, var_name: &str) -> Result

The core method of the trait: it provides the implementation to be used by [CType::c_var], by bringing a Formatter in scope. Read more
source§

fn c_define_self(_: &mut dyn Definer) -> Result<()>

Necessary one-time code for [CType::c_var]() to make sense. Read more
source§

fn csharp_define_self(_: &mut dyn Definer) -> Result<()>

Extra typedef code (e.g. [LayoutKind.Sequential] struct ...)
source§

fn csharp_ty() -> String

Type name (e.g., int, string, IntPtr)
§

type OPAQUE_KIND = Concrete

source§

fn c_short_name() -> ImplDisplay<Self>

Convenience function for callers / users of types implementing CType. Read more
source§

fn c_var(var_name: &str) -> ImplDisplay<'_, Self>

Convenience function for callers / users of types implementing CType. Read more
source§

fn legacy_csharp_marshaler() -> Option<String>

Optional marshaler attached to the type (e.g., [MarshalAs(UnmanagedType.FunctionPtr)])
source§

fn csharp_var(var_name: &str) -> String

Convenience function for formatting {ty} {var} in CSharp.
source§

impl Ord for c_char

source§

fn cmp(&self, other: &c_char) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for c_char

source§

fn eq(&self, other: &c_char) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for c_char

source§

fn partial_cmp(&self, other: &c_char) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ReprC for c_char

§

type CLayout = c_char

The CType having the same layout as Self.
source§

fn is_valid(_: &Self::CLayout) -> bool

Sanity checks that can be performed on an instance of the CType layout. Read more
source§

impl Copy for c_char

source§

impl Eq for c_char

source§

impl StructuralPartialEq for c_char

Auto Trait Implementations§

§

impl Freeze for c_char

§

impl RefUnwindSafe for c_char

§

impl Send for c_char

§

impl Sync for c_char

§

impl Unpin for c_char

§

impl UnwindSafe for c_char

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsOut<T> for T
where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, T>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CType for T
where T: LegacyCType,

§

type OPAQUE_KIND = <T as LegacyCType>::OPAQUE_KIND

source§

fn short_name() -> String

source§

fn define_self__impl( _: &(dyn HeaderLanguage + 'static), _: &mut dyn Definer ) -> Result<(), Error>

source§

fn define_self( language: &(dyn HeaderLanguage + 'static), definer: &mut dyn Definer ) -> Result<(), Error>

source§

fn name(language: &(dyn HeaderLanguage + 'static)) -> String

source§

fn name_wrapping_var( language: &(dyn HeaderLanguage + 'static), var_name: &str ) -> String

source§

fn csharp_marshaler() -> Option<String>

Optional marshaler attached to the type (e.g., [MarshalAs(UnmanagedType.FunctionPtr)])
source§

fn zeroed() -> Self

source§

impl<T> CompatExt for T

source§

fn compat(self) -> Compat<T>

Applies the Compat adapter by value. Read more
source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
source§

impl<T> ConcreteReprC for T
where <T as ReprC>::CLayout: CType<OPAQUE_KIND = Concrete>, T: ReprC + ?Sized,

source§

impl<T> FitForCBox for T

§

type CBoxWrapped = Box_<T>

Available on crate feature alloc only.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

source§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UpcastAny for T
where T: 'static,

source§

fn upcast_any(&self) -> &(dyn Any + 'static)

Available on crate feature headers only.