Struct candid::types::internal::TypeContainer [−][src]
pub struct TypeContainer {
pub env: TypeEnv,
}
Expand description
Used for candid_derive::export_service
to generate TypeEnv
from Type
.
It performs a global rewriting of Type
to resolve:
- Duplicate type names in different modules/namespaces.
- Give different names to instantiated polymorphic types.
- Find the type name of a recursive node
Knot(TypeId)
and convert toVar
node.
There are some drawbacks of this approach:
- The type name is based on
type_name::<T>()
, whose format is unspecified and long. We use some regex to shorten the name. - Several Rust types can map to the same Candid type, and we only get to remember one name (currently we choose the shortest name). As a result, some of the type names in Rust is lost.
- Unless we do equivalence checking, recursive types can be unrolled and assigned to multiple names.
Fields
env: TypeEnv
Implementations
Trait Implementations
Returns the “default value” for a type. Read more