pub trait Type: Send + Sync {
// Required methods
fn size(&self) -> usize;
fn clone_box(&self) -> Box<dyn Type>;
fn repr(&self) -> TypeRepr;
// Provided methods
fn space(&self) -> Option<MemorySpaceId> { ... }
fn fields(&self) -> Option<&[AggregateField]> { ... }
fn struct_name(&self) -> Option<&str> { ... }
fn function_return_owner(&self) -> Option<FunctionId> { ... }
fn pointee(&self) -> Option<TypeId> { ... }
fn array(&self) -> Option<(TypeId, usize)> { ... }
fn list(&self) -> Option<(TypeId, Option<usize>)> { ... }
}Required Methods§
Sourcefn clone_box(&self) -> Box<dyn Type>
fn clone_box(&self) -> Box<dyn Type>
Clones this type into a fresh boxed trait object.
This enables Clone for Box<dyn Type> (and hence Clone for
TypeManager and Context), which the GUI
relies on to fork a context before running an analysis pipeline.
Sourcefn repr(&self) -> TypeRepr
fn repr(&self) -> TypeRepr
Describes this type in a flat, serializable form.
Used to persist the TypeManager across a saved session: trait objects
cannot be serialized directly, so each type reports a TypeRepr from
which it can be reconstructed.
Provided Methods§
Sourcefn space(&self) -> Option<MemorySpaceId>
fn space(&self) -> Option<MemorySpaceId>
The memory space this type lives in, if it is a pointer type.
Sourcefn fields(&self) -> Option<&[AggregateField]>
fn fields(&self) -> Option<&[AggregateField]>
The ordered field types, if this is an AggregateType or nominal
StructType.
Sourcefn struct_name(&self) -> Option<&str>
fn struct_name(&self) -> Option<&str>
The name of this type, if it is a nominal StructType.
Sourcefn function_return_owner(&self) -> Option<FunctionId>
fn function_return_owner(&self) -> Option<FunctionId>
Owning function when this is its unique, editable return-record type.
Sourcefn array(&self) -> Option<(TypeId, usize)>
fn array(&self) -> Option<(TypeId, usize)>
The (elem, count) pair, if this is an ArrayType. Returns None for
every other type — this is the only discriminator element-aware code
uses to tell an array from the width-N scalar it otherwise looks like.
Sourcefn list(&self) -> Option<(TypeId, Option<usize>)>
fn list(&self) -> Option<(TypeId, Option<usize>)>
The (elem, bound) pair, if this is a ListType — a variable-length
sequence whose bound is the static element upper bound (Some(n)) or
None when unbounded (a pointer-sourced string). Returns None (the outer
option) for every non-list type. This is the discriminator that tells a
list (take_while’s result) from a fixed-length array:
both look like width-N scalars structurally, but a list’s length is not
statically known.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".