Websocket 如何转换向量<;u8>;进入bson::document::document?

Websocket 如何转换向量<;u8>;进入bson::document::document?,websocket,rust,binary,bson,Websocket,Rust,Binary,Bson,我会从客户那里收到包含bson文件的文件。我可以将tungstenite::Message转换为Vec,但如何在服务器端将其转换回 大概是这样的:- if msg.is_binary() { let bin = msg.into_data(); let doc = mongodb::bson::Document::from_reader(&mut bin); //getting error } 错误:- error[E0277]: the trait bound `std:

我会从客户那里收到包含bson文件的文件。我可以将
tungstenite::Message
转换为
Vec
,但如何在服务器端将其转换回

大概是这样的:-

if msg.is_binary() {
   let bin = msg.into_data();
   let doc = mongodb::bson::Document::from_reader(&mut bin); //getting error
}
错误:-

error[E0277]: the trait bound `std::vec::Vec<u8>: std::io::Read` is not satisfied
   --> src/main.rs:52:60
    |
52  |             let doc = mongodb::bson::Document::from_reader(&mut bin);
    |                                                            ^^^^^^^^ the trait `std::io::Read` is not implemented for `std::vec::Vec<u8>`
    | 
   ::: /home/voldimot/.cargo/registry/src/github.com-1ecc6299db9ec823/bson-1.0.0/src/document.rs:530:27
    |
530 |     pub fn from_reader<R: Read + ?Sized>(reader: &mut R) -> crate::de::Result<Document> {
    |                           ---- required by this bound in `bson::document::Document::from_reader`
error[E0277]:未满足特性绑定'std::vec::vec:std::io::Read'
-->src/main.rs:52:60
|
52 |让doc=mongodb::bson::Document::from_reader(&mutbin);
|^^^^^^^^特性'std::io::Read'未为'std::vec::vec'实现`
| 
::/home/voldimot/.cargo/registry/src/github.com-1ec6299db9ec823/bson-1.0.0/src/document.rs:530:27
|
530 | pub fn来自_reader(reader:&mut R)->板条箱::de::结果{
|----此绑定在'bson::document::document::from_reader'中需要`
您可以使用:

如果msg.is_binary(){
让mut bin=std:::io::Cursor::new(msg.into_data());
让doc=mongodb::bson::Document::from_reader(&mutbin);
}

您发布的代码有什么错误?请在问题中粘贴错误的完整文本。