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
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ยง
sourceยงimpl Ord for CType
impl Ord for CType
1.21.0 ยท sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
sourceยงimpl PartialEq for CType
impl PartialEq for CType
sourceยงimpl PartialOrd for CType
impl PartialOrd for CType
1.0.0 ยท sourceยงfn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more