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 to Var 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

impl TypeContainer[src]

pub fn new() -> Self[src]

pub fn add<T: CandidType>(&mut self) -> Type[src]

Trait Implementations

impl Default for TypeContainer[src]

fn default() -> TypeContainer[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.