Find_one_and_update returns EndOfStream error

Hey how’s it going. Been experimenting with the rust driver lately and have been running into this problem when I try to do a find_one_and_update() call where I get thrown a BsonDeserialization(EndOfStream) error result. The query and update seem to go through and makes the changes that I intend, but I returned an Err type :confused:

I am just curious if there is much documentation on EndOfStream error. Haven’t really found much on it, but I am assuming it has something to do with one of the docs that I am passing to the function that’s causing problems.

If this is a more complicated issue, let me know and I can give more details on filter/query/schema (I just need permission from my boss if I can post certain things).

oops, acidentally deleted my own post lol

Fixed my problem. Dumb mistake, basically what was happening was coming from here:

let devices_collection = self.db.database("deviceManagement").collection::<models::device_schema::Device>("devices");

Basically, to test some queries, I set up a slimmed down version of my schema but told bson, deserialize the output from the update call as the fully fleshed out schema. Obviously was getting EndOfStream error since…the deserializer was done deserializing but had missing values!

So imagine I had something like the following as my schema

pub struct Device{
    pub id: String,
    pub name: String,
    pub tags: Vec<String>,
}

but the documents I inserted into my database are as such

{
 id: 1,
 name: Bob
}

I think the deserializer realized there were values missing, and thus couldn’t package into the models::device_schema::Device format.

What I did to temporarly solve the issue (just to see my queries in action), was I did the following:

        let devices_collection = self.db.database("deviceManagement").collection::<Document>("devices");

basically told the deserializer to just hand me back as type bson document.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.