Skip to content

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

@bn-c

Description

@bn-c

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions