title: Create a generic find function for mongodb in Rust
body: <p>I'm trying to create a method to which I can pass a mongodb connection pool, an objectId and the collection name to retrieve data.</p>
  <p>I came up with the code below but which doesn't compile because of the following error:</p>
  <blockquote>
  <p>error: the method <code>find_one</code> exists for struct
  <code>mongodb::Collection&lt;T&gt;</code>, but its trait bounds were not satisfied
  label: method cannot be called on <code>mongodb::Collection&lt;T&gt;</code> due to
  unsatisfied trait bounds note: the following trait bounds were not
  satisfied: <code>T: DeserializeOwned</code> <code>T: Unpin</code> <code>T: std::marker::Send</code> <code>T: Sync</code> label: method cannot be called on <code>mongodb::Collection&lt;T&gt;</code> due
  to unsatisfied trait bounds</p>
  </blockquote>
  <p>What I'm I doing wrong?</p>
  <pre><code>pub async fn generic_find_by_id&lt;T&gt;(db: &amp;AppContext, object_id: String, collection_name: &amp;str) -&gt; Option&lt;T&gt; {
      let collection = db.mongodb_pool.collection::&lt;T&gt;(collection_name);
      
      let id_obj = ObjectId::parse_str(object_id);
  
      let found = match id_obj {
          Ok(id) =&gt; {
              let filter = doc! {&quot;_id&quot;: id};
              let result = collection.find_one(filter, None).await;
              match result {
                  Ok(result) =&gt; {
                      match result {
                          Some(result) =&gt; {
                              return Some(result);
                          }
                          None =&gt; {
                              return None;
                          }
                      }
                  }
                  Err(_) =&gt; {
                      return None;
                  }
              }
          }
          Err(_) =&gt; {
              return None;
          }
      };
  }    
  </code></pre>