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
sourceimpl CType
impl CType
pub fn size_of(&self) -> usize
pub fn align_of(&self) -> usize
pub const fn void() -> Self
sourcepub fn name_within_lib(&self) -> String
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.
sourcepub fn embedded_types(&self) -> Vec<CType>
pub fn embedded_types(&self) -> Vec<CType>
Lists all other types this type refers to.
sourcepub fn deref_pointer(&self) -> Option<&CType>
pub fn deref_pointer(&self) -> Option<&CType>
If this was a pointer type, tries to deref it and return the inner type.
sourcepub fn as_composite_type(&self) -> Option<&CompositeType>
pub fn as_composite_type(&self) -> Option<&CompositeType>
Convenience method attempting to convert the contained type as a composite.
sourcepub fn as_opaque_type(&self) -> Option<&OpaqueType>
pub fn as_opaque_type(&self) -> Option<&OpaqueType>
Convenience method attempting to convert the contained type as an opaque.
sourcepub fn is_void(&self) -> bool
pub fn is_void(&self) -> bool
Checks if this is a PrimitiveType::Void
.
Trait Implementations
sourceimpl Ord for CType
impl Ord for CType
sourceimpl PartialOrd<CType> for CType
impl PartialOrd<CType> for CType
sourcefn partial_cmp(&self, other: &CType) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
impl Eq for CType
impl StructuralEq for CType
impl StructuralPartialEq for CType
Auto Trait Implementations
impl RefUnwindSafe for CType
impl Send for CType
impl Sync for CType
impl Unpin for CType
impl UnwindSafe for CType
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