TryFromModule

Trait TryFromModule 

Source
pub trait TryFromModule {
    // Required method
    fn try_from_module(
        module: &Module,
    ) -> impl Future<Output = Result<Option<Self>>>
       where Self: Sized;

    // Provided methods
    fn try_from_config(config: &Config) -> impl Future<Output = Result<Self>>
       where Self: Sized { ... }
    fn try_from_modules(
        modules: &Vec<Module>,
    ) -> impl Future<Output = Result<Self>>
       where Self: Sized { ... }
}
Expand description

Creates a state from a config module. This is for a single state, which is required to be built. For multiple states see TryManyFromModule. This does not disallow for defining the module multiple times. In such a case the first module that is sorted into the Vec of the config or the provided Vec will be the winner.

Required Methods§

Source

fn try_from_module( module: &Module, ) -> impl Future<Output = Result<Option<Self>>>
where Self: Sized,

Builds the state from a module

§Return
  • Option::None - if the module is not compatible with this state
  • Option::Some - if the state could be built from the module
§Errors
  • This might return an error if the module and state is compatible but the state still could not be built because of an actual error

Provided Methods§

Source

fn try_from_config(config: &Config) -> impl Future<Output = Result<Self>>
where Self: Sized,

Simplifies building from the root config struct

§Return
  • The built module
§Errors
  • Forwards for whatever reason the module could not be made
Source

fn try_from_modules(modules: &Vec<Module>) -> impl Future<Output = Result<Self>>
where Self: Sized,

Simplifies building from multiple modules

§Return
  • The built module
§Errors
  • Forwards for whatever reason the module could not be made

Implementations on Foreign Types§

Source§

impl<T: TryFromModule> TryFromModule for Option<T>

Source§

async fn try_from_modules(modules: &Vec<Module>) -> Result<Self>
where Self: Sized,

Source§

async fn try_from_module(module: &Module) -> Result<Option<Self>>
where Self: Sized,

Implementors§