Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-904

Rust driver futures must be Sync + Send

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      Rust futures executes in multi-threaded runtime.  Because of this mongodb driver must support multi-threaded runtime. It's means that almost every structure in mongodb driver must implement Sync and Send traits. Also it's means that every future that produces this driver must implement Sync and Send traits. But currently mongodb driver does't do this.

      Steps to reproduce:

      1) Write function test_send_sync

      Unable to find source-code formatter for language: rust. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      fn test_send_sync<T>(_: T) where T: Send + Sync {}
      

      2) Create connection and open database. Create future and pass it into test_send_sync.

      Unable to find source-code formatter for language: rust. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      fn test_send_sync<T>(_: T) where T: Send + Sync {}
      
      async fn test_run_command() -> Result<()> {    
      let client = Client::with_uri_str("mongodb://localhost:27017").await?;    
      let database = client.database("_");    
      let future = database.run_command(bson::doc!{}, None);    
      test_send_sync(future);    
      return Ok(());
      }
      

      3) Code will not compiled because future is not implemented Send and Sync trait

       

      Expectations:

      This code will be compiled correctly. All futures must implement Send + Sync!

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            svmk-tmsk@yandex.ru Mickle Svetov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: