Skip to content

can't figure out how to spawn a future with async trait functions #5904

Answered by Darksonn
softstream-link asked this question in Q&A
Discussion options

You must be logged in to vote

For now, I think the only way to work around it is the following:

trait ProtocolInitHandler: Sync + Send + 'static {
    fn login_sequence(&self) -> impl Future<Output = ()> + Send + '_;
}

impl ProtocolInitHandler for SvcProtocolInitHandler {
    async fn login_sequence(&self) {
        println!("login sequence do something");
    }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by softstream-link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants