pub trait UniversalWallet: Sized + 'static {
// Required methods
fn get_child_links(schema: &mut Schema) -> Vec<Link>;
fn scaffold() -> Item<IndexLinking>;
// Provided methods
fn write_schema(schema: &mut Schema) -> Link { ... }
fn make_root_of(schema: &mut Schema) { ... }
fn get_child_templates(_schema: &mut Schema) -> TransactionTemplateSet { ... }
fn make_linkable(schema: &mut Schema) -> Link { ... }
fn id_override() -> Option<ItemId> { ... }
}Expand description
Generate the schema for a type.
For complex types, this should typically be derived with a macro,
rather than implemented by hand.
This is also automatically implemented for all types implementing OverrideSchema.
Required Methods§
Sourcefn get_child_links(schema: &mut Schema) -> Vec<Link>
fn get_child_links(schema: &mut Schema) -> Vec<Link>
Ensure that each type contained in the outer type (i.e. the type of each struct/tuple field) is added to the schema,
and return a Link connecting the child to the parent.
Ideally, this function would return something like Box<dyn UniversalWallet>.
Unfortunately, we need to return types, not instances (because we don’t want to
add a Default bound on all types that implement UniversalWallet) which Rustc doesn’t like.
So, we have a slightly messier signature where the type is expected to register each of its child
types with the schema directly rather than returning them to the caller for future registration.
Sourcefn scaffold() -> Item<IndexLinking>
fn scaffold() -> Item<IndexLinking>
Generate the “scaffolding” of the item. If the item is a primtive, this is just the corresponding primtive.
If the type is composed of other types, this is the container with all links set to Link::Placeholder.
Provided Methods§
Sourcefn write_schema(schema: &mut Schema) -> Link
fn write_schema(schema: &mut Schema) -> Link
Writes the type to the schema if it is not already present and returns a link to it.
Any child types will have their schemas generated as well, but the placement of those types is left to the discretion of the implementation - they may or may not appear at the top level of the schema.
Sourcefn make_root_of(schema: &mut Schema)
fn make_root_of(schema: &mut Schema)
Writes the type and all its children to the schema, if not already present, and sets the type as a root type. Generates any templates defined on that type.
Sourcefn get_child_templates(_schema: &mut Schema) -> TransactionTemplateSet
fn get_child_templates(_schema: &mut Schema) -> TransactionTemplateSet
Empty by default When derived by the macro, builds a template set from annotations on the fields + the field types’ own get_child_templates()
Sourcefn make_linkable(schema: &mut Schema) -> Link
fn make_linkable(schema: &mut Schema) -> Link
Gets a link to the type, writing the type to the schema if necessary.
Sourcefn id_override() -> Option<ItemId>
fn id_override() -> Option<ItemId>
Override the type ID of the item. This should typically not be written by hand. Instead,
use the OverrideSchema trait.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.