{
  "path": "/3mk2euuyec222",
  "site": "at://did:plc:nuc33thnsiqzhytkleyr5jek/site.standard.publication/3mjt5n4e4222m",
  "tags": [
    "rust",
    "atproto",
    "jacquard",
    "rust-traits"
  ],
  "$type": "site.standard.document",
  "title": "The trait 'jacquard::types::collection::Collection' is not implemented for CreateRecord<'_>",
  "content": {
    "$type": "pub.leaflet.content",
    "pages": [
      {
        "id": "019db2cd-734e-7ddf-a93f-ea67530ac364",
        "$type": "pub.leaflet.pages.linearDocument",
        "blocks": [
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.code",
              "language": "rust",
              "plaintext": "use clap::Parser;\nuse jacquard::api::com_atproto::repo::create_record::CreateRecord;\nuse jacquard::client::{Agent, AgentSessionExt, FileAuthStore};\nuse jacquard::oauth::client::OAuthClient;\nuse jacquard::oauth::loopback::LoopbackConfig;\nuse jacquard::types::string::Datetime;\nuse jacquard::CowStr;\nuse jacquard_common::types::ident::AtIdentifier;\nuse jacquard_common::types::string::Nsid;\nuse jacquard_common::types::value::Data;\nuse serde_json::json;\n\n#[derive(Parser, Debug)]\n#[command(author, version, about = \"Create a bookmark record\")]\nstruct Args {\n    // Handle (e.g., hyperreal.at.moonshadow.dev), DID, or PDS URL\n    input: CowStr<'static>,\n\n    // Bookmark title\n    #[arg(short, long)]\n    title: String,\n\n    // Bookmark URL\n    #[arg(short, long)]\n    url: String,\n\n    // Bookmarks tags\n    #[arg(short, long)]\n    tags: Vec<String>,\n\n    // Path to auth store file (will be created if missing)\n    #[arg(long, default_value = \"/tmp/jacquard-oauth-session.json\")]\n    store: String,\n}\n\n#[tokio::main]\nasync fn main() -> miette::Result<()> {\n    let args = Args::parse();\n\n    let oauth = OAuthClient::with_default_config(FileAuthStore::new(&args.store));\n    let session = oauth\n        .login_with_local_server(args.input, Default::default(), LoopbackConfig::default())\n        .await?;\n\n    let agent: Agent<_> = Agent::from(session);\n\n    //let linkding_host =\n    //std::env::var(\"LINKDING_HOST\").unwrap_or(\"http://localhost:10407\".to_string());\n    //let linkding_token =\n    //std::env::var(\"LINKDING_TOKEN\").expect(\"LINKDING_TOKEN env variable is not set\");\n    //let linkding_client = LinkDingClient::new(&linkding_host, &linkding_token);\n\n    // Create JSON record for monomark item\n    let json_record = json!({\n        \"url\": Some(args.url),\n        \"tags\": Some(args.tags),\n        \"$type\": \"at.monomarks.bookmark\",\n        \"title\": Some(args.title),\n        \"createdAt\": Some(Datetime::now())\n    });\n\n    let bookmark_record = CreateRecord {\n        collection: Nsid::new(\"at.monomarks.bookmark\")?,\n        record: Data::from_json(&json_record)?,\n        repo: AtIdentifier::new(\"did:plc:nuc33thnsiqzhytkleyr5jek\")?,\n        extra_data: None,\n        rkey: None,\n        swap_commit: None,\n        validate: None,\n    };\n\n    let output = agent.create_record(\n        bookmark_record,\n        None\n    ).await?;\n    println!(\"Created monomark item: {}\", output.uri);\n\n    Ok(())\n}",
              "syntaxHighlightingTheme": "catppuccin-mocha"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 44,
                    "byteStart": 23
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 133,
                    "byteStart": 94
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 170,
                    "byteStart": 155
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 191,
                    "byteStart": 179
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 245,
                    "byteStart": 228
                  },
                  "features": [
                    {
                      "uri": "https://docs.rs/jacquard/latest/jacquard/types/collection/trait.Collection.html",
                      "$type": "pub.leaflet.richtext.facet#link"
                    }
                  ]
                }
              ],
              "plaintext": "In the code above, the agent.create_record() method requires a type that implements the trait jacquard::types::collection::Collection. The problem is that bookmark_record's type, CreateRecord, does not implement that trait. The types listed here are the only ones that implement that trait."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 69,
                    "byteStart": 61
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                },
                {
                  "index": {
                    "byteEnd": 243,
                    "byteStart": 231
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                }
              ],
              "plaintext": "The various examples I've seen using jacquard use types like Post<,_> that implement that trait. Each type seems to be pre-defined for the given NSID. at.monomarks.bookmark does not have a type defined for it. So my intention with CreateRecord was to try to create a generic record."
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 267,
                    "byteStart": 263
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                }
              ],
              "plaintext": "Is there a way to create such a generic record with Rust? Do I have to create a type myself for at.monomarks.bookmark that implements the required trait? Would it be easier, for me as an absolute beginner, to do the Rust equivalent of sending a POST request with curl to the XRPC API?"
            }
          },
          {
            "$type": "pub.leaflet.pages.linearDocument#block",
            "block": {
              "$type": "pub.leaflet.blocks.text",
              "facets": [
                {
                  "index": {
                    "byteEnd": 71,
                    "byteStart": 67
                  },
                  "features": [
                    {
                      "$type": "pub.leaflet.richtext.facet#code"
                    }
                  ]
                }
              ],
              "plaintext": "Is there so much to unpack here that I should just give up and use curl or Python? Lol."
            }
          }
        ]
      }
    ]
  },
  "bskyPostRef": {
    "cid": "bafyreibavloqymfv4wrf6txt4n3m6bvp5hqw7jmqiae5qmylftrqxxe2gy",
    "uri": "at://did:plc:nuc33thnsiqzhytkleyr5jek/app.bsky.feed.post/3mk2euznrk222",
    "commit": {
      "cid": "bafyreidbqxt4xlt3nxr66xohwjrwlvvej6gxzej7gesd7ceg2ixkqsn7pq",
      "rev": "3mk2euzr3yc2t"
    },
    "validationStatus": "valid"
  },
  "description": "",
  "publishedAt": "2026-04-22T01:47:04.228Z"
}