Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(iroh-router)!: change accept to take an AsRef<[u8]> (#2963)
## Description Change RouterBuilder::accept to take an AsRef<[u8]> instead of a Vec<u8>. Also change iroh node accept. ## Breaking Changes - RouterBuilder::accept takes impl AsRef<[u8]>. Existing code should still work! - Node::accept takes impl AsRef<[u8]>. Existing code should still work! ## Notes & open questions Question: since we are making the API more pleasant at the expense of a bit of inefficiency, should we also change the second parameter to take a &Arc instead of an Arc? So ```rust fn accept(alpn: impl AsRef<[u8]>, proto: &Arc<dyn ProtocolHandler>) ``` In the various examples I found that you very frequently need the protocol handler again after accept-ing it. So this saves one .clone() in many cases, at the expense of an arc clone, which we basically treat as free anyway. ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented.
- Loading branch information