ResolveMapping

Trait ResolveMapping 

Source
pub trait ResolveMapping:
    'static
    + Sync
    + Send
    + Sized {
    // Required method
    fn mapping(mapper: &mut Mapper<Self>);
}
Expand description

ResolveMapping is a trait that defines the mapping of event types to their respective handlers.

§Example

use nitinol_resolver::mapping::{Mapper, ResolveMapping};

#[async_trait]
impl SubscribeHandler<EntityEvent> for Entity {
    type Rejection = String;
    async fn on(&mut self, event: EntityEvent) -> Result<(), Self::Rejection> {
        // something process...
        Ok(())
    }
}

impl ResolveMapping for Entity {
    fn mapping(mapper: &mut Mapper<Self>) {
        // Register the event type and its handler
        // This `Subscribe` shown as an example points out a compile error,
        // if the above `SubscribeHandler` is not implemented for the Entity type.
        mapper.register::<EntityEvent, Subscribe>();
    }
}

Required Methods§

Source

fn mapping(mapper: &mut Mapper<Self>)

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§