Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing Ergonomics for Docs and Authors Client #20

Open
Zyell opened this issue Dec 10, 2024 · 1 comment
Open

Typing Ergonomics for Docs and Authors Client #20

Zyell opened this issue Dec 10, 2024 · 1 comment

Comments

@Zyell
Copy link

Zyell commented Dec 10, 2024

When implementing user code that needs to type a parameter that should be either a Doc or Author Client, it currently requires adding quic-rpc as a dependency. The following example shows the current situation:

use iroh_docs::rpc::client::authors::Client;
use iroh_docs::rpc::client::docs::Doc;
use iroh_docs::rpc::proto::{Request, Response};
use quic_rpc::transport::flume::FlumeConnector;

pub struct ApplicationClient {
    // ... //
    blobs: iroh_blobs::rpc::client::blobs::MemClient,
    docs: iroh_docs::rpc::client::docs::MemClient,
}

impl ApplicationClient {
    // ... //
    fn authors(
        &self,
    ) -> Client<FlumeConnector<Response, Request>> {
        self.docs.authors()
    }
    
    async fn create_doc(
        &self,
    ) -> anyhow::Result<Doc<FlumeConnector<Response, Request>>> {
        self.docs.create().await
    }
}

Both the Doc and Blobs Clients have a special type declared to avoid having to make quic-rpc a hard dependency in user code. Could such types be created for both Doc and the Author Client?

@matheus23
Copy link
Contributor

Could such types be created for both Doc and the Author Client?

That's one solution, the other would be to use BoxedConnector for the in-memory clients.
The Client and Doc types already have a default for their generic parameter that is set to BoxedConnector. This would plug in nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants