Skip to content

refactor(workspace): prefer native async fn in traits over BoxFuture - #698

Open
varex83agent wants to merge 1 commit into
mainfrom
fix/issue-613-native-afit
Open

refactor(workspace): prefer native async fn in traits over BoxFuture#698
varex83agent wants to merge 1 commit into
mainfrom
fix/issue-613-native-afit

Conversation

@varex83agent

Copy link
Copy Markdown
Collaborator

Closes #613.

Traits that are never used as dyn now use native async-fn-in-trait, spelled -> impl Future + Send where generic callers need the Send bound to spawn the returned future. #[async_trait] is kept only on the traits genuinely held as dyn (consensus::wrapper::Consensus, dkg::bcast::RegisteredMessage), each with a doc comment recording why.

Deletes the boxed-future trait methods that merely wrapped already-async inherent methods, unboxes priority's send_receive, and drops core's duplicate BoxFuture alias in favour of futures::future::BoxFuture.

Out of scope and untouched: the libp2p ConnectionHandler state-machine BoxFutures, and the subscriber callback type aliases owned by #606.

Co-Authored-By: Bohdan Ohorodnii 35969035+varex83@users.noreply.github.com

Traits that are never used as `dyn` now use native async-fn-in-trait
(spelled `-> impl Future + Send` where generic callers need to spawn the
returned future); `#[async_trait]` is reserved for the traits that are
genuinely held as `dyn`. Deletes the boxed-future trait methods that only
wrapped already-async inherent methods and drops core's duplicate
`BoxFuture` alias in favour of `futures::future::BoxFuture`.

libp2p `ConnectionHandler` state-machine `BoxFuture`s and the subscriber
callback type aliases (#606) are left untouched.

Closes #613.

Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Prefer native async fn in traits over BoxFuture; reserve async-trait for dyn traits

2 participants