"the trait bound is not satisfied" error - why?

I got "the trait bound is not satisfied" error but can't understand why.
This is a trait implementation

pub struct QueryParser<T> {
    indexes: Vec<String>,
    phantom: PhantomData<T>,

impl<'a, T> BeforeMiddleware for QueryParser<T>
    T: QueryKey + Send + Sync,
    <T as Key>::Value: Query + DeserializeOwned,
    fn before(&self, request: &mut Request) -> IronResult<()> {

And this is it usage


And this is error

error[E0277]: the trait bound `query_parser::QueryParser<list::filter::FilterKey>: iron::middleware::BeforeMiddleware` is not satisfied
  --> src/main.rs:33:23
33 |     chain.link_before(QueryParser::<FilterKey>::new(&cfg.indexes));
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `iron::middleware::BeforeMiddleware` is not implemented for `query_parser::QueryParser<list::filter::FilterKey>`
   = help: the following implementations were found:
             <query_parser::QueryParser<T> as iron::middleware::BeforeMiddleware>

Compiler even say than "the following implementations were found". What's wrong?????

What libraries are you using? I see iron, but I don't know what FilterKey or QueryParser or QueryKey actually are. Does FilterKey implement the needed traits?

1 Like

This is my wrappers for iron's TypeMap. This is it

pub trait Query {
    fn get_index(&self) -> Option<usize>;
    fn set_index_name(&mut self, name: Option<String>);

pub trait QueryKey: Key
    Self::Value: Query,

Hmm... maby you right. Thanks!

I really forgot to implement for FilterKey. :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.