unsegen::container

Trait ContainerProvider

Source
pub trait ContainerProvider {
    type Context;
    type Index: Clone + PartialEq + Debug;

    const DEFAULT_CONTAINER: Self::Index;

    // Required methods
    fn get<'a, 'b: 'a>(
        &'b self,
        index: &'a Self::Index,
    ) -> &'b dyn Container<Self::Context>;
    fn get_mut<'a, 'b: 'a>(
        &'b mut self,
        index: &'a Self::Index,
    ) -> &'b mut dyn Container<Self::Context>;
}
Expand description

A ContainerProvider stores the individual components (Containers) of an application and allows them to be retrieved based on an index.

Note that every possible value for Self::Index must correspond to a valid component. A good choice for an Index is therefore an enum.

Required Associated Constants§

Source

const DEFAULT_CONTAINER: Self::Index

The container selected by default (i.e., the start of the application)

Required Associated Types§

Source

type Context

Type to be passed as a parameter to Container::input.

Source

type Index: Clone + PartialEq + Debug

Type that enumerates and identifies all containers.

Required Methods§

Source

fn get<'a, 'b: 'a>( &'b self, index: &'a Self::Index, ) -> &'b dyn Container<Self::Context>

Get the container identified by the index.

Source

fn get_mut<'a, 'b: 'a>( &'b mut self, index: &'a Self::Index, ) -> &'b mut dyn Container<Self::Context>

Get the container identified by the index (mutable).

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.

Implementors§