Skip to content

Typing Ergonomics for Docs and Authors Client #20

@Zyell

Description

@Zyell

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?

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