n0-computer / n0-computer/iroh-docs

[Rust] How to store and reuse `Doc<>` struct in my application?

Open
#30 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
74
Forks
16
PR merge metrics
No merged PRs in 30d

Description

Overview:

  • The README.md example snippets shows how to create a Docs<Store> struct in rust
let docs: Docs<Store> = Docs::memory().spawn(&blobs, &gossip).await?;
  • However, when I create a client, and a document, the rust types for these structs are complex, part of it is even private i.e. quic-rpc / Connection
    let docs_client = docs.client();
    let doc = docs_client.create().await?;

I'm running into the following issue:

  • It is not clear, what is the intended lifecycle of these structs.
    • Should I save the instance and passing them around my applications's struct/function to implement my logic? (Complicated typing leads to compiler headaches)
    • Or treat them as one-off instance, and instead clone the Docs<Store> struct & NamespaceID, then uses it to spawn in the document client when ever needed. (Seems to not be ideal, performance wise)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the README.md Rust example using Docs::memory().spawn, then inspect the docs.client() and create() entry points mentioned in the issue. Clarify the intended lifecycle and reusable application-facing types for Docs, the client, and NamespaceID, and document the guidance in the README.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.