Skip to content

Commit

Permalink
refactor(iroh): use boxed client to get rid of the C type parameter (#…
Browse files Browse the repository at this point in the history
…2353)

## Description

I implemented a boxed connection and a boxed service endpoint in
quic-rpc.

With this we can get rid of the `<C: ServiceConnection<RpcService>` type
parameter and make the quinn and mem client/server side the same type.

The nice thing about this approach is that it will not lead to additonal
boxing on the mem path, and for the quinn or whatever io path the boxing
will probably not matter that much compared to all the other things
going on.

## Breaking Changes

Breaking changes affect solely the iroh client.

The iroh client as well as all the subsystem clients no longer need a
type parameter C to distinguish between an in memory connection and a
remote connection.

- Code that directly uses the clients should be unaffected. E.g.
`iroh.blobs().read(hash)` will still compile.

- Code that takes a client as an argument will have to be modified to
remove the type parameter. E.g.

```rust
fn download<C>(client: blobs::Client<C>) where C: ...
```

will become just

```rust
fn download(client: blobs::Client)
```

The type aliases `iroh::client::MemIroh` and `iroh::client::QuicIroh`
for an iroh client specialized for memory or remote use have been
retained, but will be removed in one of the next releases.

In detail:

- iroh::client::Iroh loses the `C` type parameter
- iroh::client::blobs::Client loses the `C` type parameter
- iroh::client::tags::Client loses the `C` type parameter
- iroh::client::authors::Client loses the `C` type parameter
- iroh::client::docs::Client loses the `C` type parameter

## Notes & open questions

Note: I marked the old type aliases MemIroh, QuicIroh etc as deprecated.
That does not seem to actually do anything, but just serves as a
reminder to remove them in the near future.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
~~- [x] Tests if relevant.~~
- [x] All breaking changes documented.
  • Loading branch information
rklaehn authored Jun 20, 2024
1 parent 7a969fc commit bf8c0ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf8c0ca

Please sign in to comment.