-
Notifications
You must be signed in to change notification settings - Fork 168
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
RUST-1120 bson's is_human_readable not configurable from mongodb side #530
Comments
Hey @alon-z, thanks for filing this issue! So the deserializer used by the driver is always non-human-readable, but it turns out that this is side-stepped by a limitation/bug in serde (see serde-rs/serde#1183). The driver runs into this because 2.0 and 2.1 use In the meantime before 2.2.0 is released, you can try depending on the Sorry for any inconvenience caused by this issue, and thanks again for bringing this to our attention! |
Hey @patrickfreed , thank you for the quick response.
But when trying to use a find command, I get the same error about parsing the address: The ipnet module will serialize in this format only when |
Hmm, are you sure you're using the master branch? You may need to run #[derive(Debug, Deserialize, Serialize)]
struct D {
addr: Ipv4Net,
}
#[tokio::main]
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
let client = Client::with_uri_str("mongodb://localhost:27017").await?;
let collection = client.database("ipv4").collection("ipv4");
collection.insert_one(D { addr: Ipv4Net::new(Ipv4Addr::new(127, 0, 0, 1), 16)? }, None).await?;
collection.insert_one(D { addr: Ipv4Net::new(Ipv4Addr::new(127, 0, 0, 1), 16)? }, None).await?;
let mut cursor = collection.find(None, None).await?;
while let Some(d) = cursor.try_next().await? {
println!("{:?}", d);
}
Ok(())
} and prints:
So, it seems like it should be working generally. |
i have to say the official docs is su*ks!!! why not give a complete demo! |
Hi @jackbbhua, can you please elaborate on what you are looking for? Our README has embedded a number of examples, as well as links to our docs.rs page which contains some further examples, and an example application using Actix. |
Hey, we are trying to save a struct with
ipnet::Ipv4Net
and the serializers are using theis_human_readable
serde option to distinguish between different cases.When inserting the struct, it serializes with
is_human_readable
false (this issue is referenced in bson's 2.1.0-beta changelog) but when using find commands, the deserializer is set withis_human_readable
true by default.In result, we cant save and use the struct in mongo.
In bson 2.1.0-beta they added options to set the
is_human_readable
variable.If there could be a way we can set it so the deserializer will set
is_human_readable
to false when using find commands, we will be able to solve this issue :)Example below
The text was updated successfully, but these errors were encountered: