-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Actually, I don't if this is a right way..
Let's say that I want to design a custom client/server, which uses bson to transfer data(like mongodb oplog or my custom defined data). But Document::from_reader and Document::to_writer is not async function, I can hardly to use it directly to send/receive data (or may cause the whole event loop hang).
As alternative, I need to read data into a vector<u8>, then invoke Document::from_reader to get actual document. But using this method, I need to parse the input stream(like read header first to know how many bytes we need to read at least).
So may be there are some relative apis to make async read/write directly from/into a Document is awesome.
But actually I don't know if serialize and deserialize document is a cpu bound task. If this is a cpu bound task, it's useless to implement these methods.
I have checked mongodb rust driver implementation, it seems that it use another abstract Message to make async interactive with mongodb. (I believe these data are also in bson format):
https://github.com/mongodb/mongo-rust-driver/blob/master/src/cmap/conn/wire/message.rs#L24
May I ask what do you think about this?