-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add tokio async support #150
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a massive! Thanks for the effort. It would be great if we can come up with some way to avoid code duplication as currently there seem to be 2 versions of code living side by side.
/// Serialize this instance into a vector of bytes. | ||
async fn try_to_vec(&self) -> Result<Vec<u8>> { | ||
let mut result = Vec::with_capacity(DEFAULT_SERIALIZER_CAPACITY); | ||
self.serialize(&mut result).await?; | ||
Ok(result) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgive my ignorance, but what is the point of using an async version of try_to_vec
? It feels like a pointless method to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are totally right!
we don't need that. i will remove it.
Thank you, yeah exactly, this is what i'm afraid of. |
It is going to be really hard to maintain and I fear that it will inevitably drift away, so I would keep it in PR for now to see if anyone will be able to come up with a better plan or maybe Rust |
Good idea, |
This PR will add support for tokio by adding two traits
AsyncBorshDeserialize
andAsyncBorshSerialize
and their respective derive macros to be used in places that we have async reader and writer.Feature gate = "tokio"
Here is works that needs to be done:
async-std
too)Anyway, here is the driver code for current working version:
Cargo.toml: