Trait anchor_lang::IdlBuild

source ·
pub trait IdlBuild {
    // Provided methods
    fn create_type() -> Option<IdlTypeDef> { ... }
    fn insert_types(_types: &mut BTreeMap<String, IdlTypeDef>) { ... }
    fn get_full_path() -> String { ... }
}
Available on crate feature idl-build only.
Expand description

A trait that types must implement in order to include the type in the IDL definition.

This trait is automatically implemented for Anchor all types that use the AnchorSerialize proc macro. Note that manually implementing the AnchorSerialize trait does NOT have the same effect.

Types that don’t implement this trait will cause a compile error during the IDL generation.

The default implementation of the trait allows the program to compile but the type does NOT get included in the IDL.

Provided Methods§

source

fn create_type() -> Option<IdlTypeDef>

Create an IDL type definition for the type.

The type is only included in the IDL if this method returns Some.

source

fn insert_types(_types: &mut BTreeMap<String, IdlTypeDef>)

Insert all types that are included in the current type definition to the given map.

source

fn get_full_path() -> String

Get the full module path of the type.

The full path will be used in the case of a conflicting type definition, e.g. when there are multiple structs with the same name.

The default implementation covers most cases.

Object Safety§

This trait is not object safe.

Implementors§