ComponentRegistry

Trait ComponentRegistry 

Source
pub trait ComponentRegistry {
    // Required methods
    fn get_component_ref<T>(&self) -> Option<ComponentRef<T>>
       where T: Any + Send + Sync;
    fn get_component<T>(&self) -> Option<T>
       where T: Clone + Send + Sync + 'static;
    fn has_component<T>(&self) -> bool
       where T: Any + Send + Sync;

    // Provided methods
    fn get_expect_component_ref<T>(&self) -> ComponentRef<T>
       where T: Clone + Send + Sync + 'static { ... }
    fn try_get_component_ref<T>(&self) -> Result<ComponentRef<T>>
       where T: Clone + Send + Sync + 'static { ... }
    fn get_expect_component<T>(&self) -> T
       where T: Clone + Send + Sync + 'static { ... }
    fn try_get_component<T>(&self) -> Result<T>
       where T: Clone + Send + Sync + 'static { ... }
}
Expand description

Component Registry

Required Methods§

Source

fn get_component_ref<T>(&self) -> Option<ComponentRef<T>>
where T: Any + Send + Sync,

Get the component reference of the specified type

Source

fn get_component<T>(&self) -> Option<T>
where T: Clone + Send + Sync + 'static,

Get the component of the specified type

Source

fn has_component<T>(&self) -> bool
where T: Any + Send + Sync,

Is there a component of the specified type in the registry?

Provided Methods§

Source

fn get_expect_component_ref<T>(&self) -> ComponentRef<T>
where T: Clone + Send + Sync + 'static,

Get the component reference of the specified type. If the component does not exist, it will panic.

Source

fn try_get_component_ref<T>(&self) -> Result<ComponentRef<T>>
where T: Clone + Send + Sync + 'static,

Get the component reference of the specified type. If the component does not exist, it will return AppError::ComponentNotExist.

Source

fn get_expect_component<T>(&self) -> T
where T: Clone + Send + Sync + 'static,

Get the component of the specified type. If the component does not exist, it will panic.

Source

fn try_get_component<T>(&self) -> Result<T>
where T: Clone + Send + Sync + 'static,

Get the component of the specified type. If the component does not exist, it will return AppError::ComponentNotExist.

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§