Watch keynotes and sessions from, our virtual developer conference.

Rust data structure example

I’m reading the documentation for this, now v1.0.0, official mongodb Rust driver.

While it shows how to insert some arbitrary data

let result = coll.insert_one(doc! { "x": 1 }, None).await?;

I’m wondering how to define data structures.

Can you show an example data structure definiton?

For instance something like

pub struct Post {
  id: bson::ObjectID
  name: String

only correct.