Skip to content

Support for inner types #37

Open
Open
@carlos-verdes

Description

@carlos-verdes

This macro fails when you have inner types as context bounds of your trait functions.

Consider you have this type:

#[trait_variant::make(Aggregate: Send)]
pub trait LocalAggregate: Default + Serialize + DeserializeOwned + Sync + Send + Stream {
    type Command: Send + Sync;

    type Error: std::error::Error + From<AggregateStoreError>;
    type Services: Send + Sync;

    fn handle(
        &self,
        command: &Self::Command,
        services: &Self::Services,
    ) -> impl Future<Output = Result<Vec<Self::Event>, Self::Error>>;
}

And you want to implement a trait where you can handle this aggregate commands like this:

#[trait_variant::make(AggregateStore: Send)]
pub trait LocalAggregateStore {

    fn apply_command_and_store_events<A: Aggregate,>(
        &self,
        stream_id: &Urn,
        stream_type: String,
        metadata: crate::Metadata,
        command: A::Command,
        expected_version: Option<i64>,
    ) -> impl Future<Output = Result<(), A::Error>>
}

This fails to compile with next error:

 --> es/src/persistence/store.rs:32:9
   |
32 |         command: A::Command,
   |         ^^^^^^^ cannot infer type
   |
   = note: cannot satisfy `<_ as Aggregate>::Command == _`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions