Skip to main content

UniversalWallet

Trait UniversalWallet 

Source
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§

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.

Source

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§

Source

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.

Source

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.

Source

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()

Source

fn make_linkable(schema: &mut Schema) -> Link

Gets a link to the type, writing the type to the schema if necessary.

Source

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.

Implementations on Foreign Types§

Source§

impl UniversalWallet for bool

Source§

impl UniversalWallet for f32

Source§

impl UniversalWallet for f64

Source§

impl UniversalWallet for i8

Source§

impl UniversalWallet for i16

Source§

impl UniversalWallet for i32

Source§

impl UniversalWallet for i64

Source§

impl UniversalWallet for i128

Source§

impl UniversalWallet for u8

Source§

impl UniversalWallet for u16

Source§

impl UniversalWallet for u32

Source§

impl UniversalWallet for u64

Source§

impl UniversalWallet for u128

Source§

impl UniversalWallet for ()

Source§

impl<K: UniversalWallet, V: UniversalWallet> UniversalWallet for HashMap<K, V>

Source§

impl<T1: UniversalWallet + 'static, T2: UniversalWallet + 'static> UniversalWallet for (T1, T2)

Source§

impl<T1: UniversalWallet + 'static, T2: UniversalWallet + 'static, T3: UniversalWallet + 'static> UniversalWallet for (T1, T2, T3)

Source§

impl<T1: UniversalWallet + 'static, T2: UniversalWallet + 'static, T3: UniversalWallet + 'static, T4: UniversalWallet + 'static> UniversalWallet for (T1, T2, T3, T4)

Source§

impl<T1: UniversalWallet + 'static, T2: UniversalWallet + 'static, T3: UniversalWallet + 'static, T4: UniversalWallet + 'static, T5: UniversalWallet + 'static> UniversalWallet for (T1, T2, T3, T4, T5)

Source§

impl<T1: UniversalWallet + 'static, T2: UniversalWallet + 'static, T3: UniversalWallet + 'static, T4: UniversalWallet + 'static, T5: UniversalWallet + 'static, T6: UniversalWallet + 'static> UniversalWallet for (T1, T2, T3, T4, T5, T6)

Source§

impl<T1: UniversalWallet + 'static, T2: UniversalWallet + 'static, T3: UniversalWallet + 'static, T4: UniversalWallet + 'static, T5: UniversalWallet + 'static, T6: UniversalWallet + 'static, T7: UniversalWallet + 'static> UniversalWallet for (T1, T2, T3, T4, T5, T6, T7)

Source§

impl<T1: UniversalWallet + 'static, T2: UniversalWallet + 'static, T3: UniversalWallet + 'static, T4: UniversalWallet + 'static, T5: UniversalWallet + 'static, T6: UniversalWallet + 'static, T7: UniversalWallet + 'static, T8: UniversalWallet + 'static> UniversalWallet for (T1, T2, T3, T4, T5, T6, T7, T8)

Source§

impl<T: 'static> UniversalWallet for PhantomData<T>

Source§

impl<T: UniversalWallet> UniversalWallet for Option<T>

Source§

impl<T: UniversalWallet> UniversalWallet for Vec<T>

Source§

impl<T: UniversalWallet> UniversalWallet for Range<T>

Source§

impl<const N: usize, T: UniversalWallet> UniversalWallet for [T; N]

Implementors§

Source§

impl<T: OverrideSchema + 'static> UniversalWallet for T

Source§

impl<const MAX_LEN: usize> UniversalWallet for SizedSafeString<MAX_LEN>