Enum interoptopus::lang::c::CType

source ยท
pub enum CType {
    Primitive(PrimitiveType),
    Array(ArrayType),
    Enum(EnumType),
    Opaque(OpaqueType),
    Composite(CompositeType),
    FnPointer(FnPointerType),
    ReadPointer(Box<CType>),
    ReadWritePointer(Box<CType>),
    Pattern(TypePattern),
}
Expand description

A type that can exist at the FFI boundary.

Variantsยง

ยง

Primitive(PrimitiveType)

ยง

Array(ArrayType)

ยง

Enum(EnumType)

ยง

Opaque(OpaqueType)

ยง

Composite(CompositeType)

ยง

FnPointer(FnPointerType)

ยง

ReadPointer(Box<CType>)

ยง

ReadWritePointer(Box<CType>)

ยง

Pattern(TypePattern)

Special patterns with primitives existing on C-level but special semantics. useful to higher level languages.

Implementationsยง

sourceยง

impl CType

source

pub fn size_of(&self) -> usize

source

pub fn align_of(&self) -> usize

source

pub const fn void() -> Self

source

pub fn name_within_lib(&self) -> String

Produces a name unique for that type with respect to this library.

The name here is supposed to uniquely determine a type relative to a library (crate::Inventory), but it is not guaranteed to be C-compatible and may contain special characters (e.g., *const u32).

Backends should instead match on the CType variant and determine a more appropriate name on a case-by-case basis; including changing a name entirely.

source

pub fn embedded_types(&self) -> Vec<CType>

Lists all other types this type refers to.

source

pub fn deref_pointer(&self) -> Option<&CType>

If this was a pointer type, tries to deref it and return the inner type.

source

pub fn as_composite_type(&self) -> Option<&CompositeType>

Convenience method attempting to convert the contained type as a composite.

source

pub fn as_opaque_type(&self) -> Option<&OpaqueType>

Convenience method attempting to convert the contained type as an opaque.

source

pub fn is_void(&self) -> bool

Checks if this is a PrimitiveType::Void.

source

pub fn namespace(&self) -> Option<&str>

Returns the namespace of the type.

Trait Implementationsยง

sourceยง

impl Clone for CType

sourceยง

fn clone(&self) -> CType

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 CType

sourceยง

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

Formats the value using the given formatter. Read more
sourceยง

impl Default for CType

sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more
sourceยง

impl Hash for CType

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 Ord for CType

sourceยง

fn cmp(&self, other: &CType) -> 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 CType

sourceยง

fn eq(&self, other: &CType) -> 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 CType

sourceยง

fn partial_cmp(&self, other: &CType) -> 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 Eq for CType

sourceยง

impl StructuralPartialEq for CType

Auto Trait Implementationsยง

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> 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> 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> 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.