Skip to content

Add support for borrowed deserialization #231

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

Closed
TedDriggs opened this issue Feb 10, 2021 · 3 comments
Closed

Add support for borrowed deserialization #231

TedDriggs opened this issue Feb 10, 2021 · 3 comments
Labels
tracked-in-jira Ticket filed in Mongo's Jira system

Comments

@TedDriggs
Copy link

I have a struct like this:

#[derive(Deserialize)]
struct Example<'a> {
    #[serde(borrow)]
    field: Option<Cow<'a, str>>,
    #[serde(borrow, default)]
    other_field: Vec<Cow<'a, str>>,
}

I'd like to use it with this crate, but the DeserializeOwned bound gets in the way.

I think the issue is that deserialization goes through Document, which in turn requires ownership of strings etc. inside it. Is that correct, and if so could that be mitigated by having a bson::borrow::Bson which points into a backing &'a [u8]?

@pooooodles
Copy link

Tracked in https://jira.mongodb.org/browse/RUST-688

@pooooodles pooooodles added the tracked-in-jira Ticket filed in Mongo's Jira system label Mar 1, 2021
@pooooodles
Copy link

Hi Ted, just wanted to follow up to let you know this is still on our radar. We'll be taking a deeper look after we wrap up the work and conversation on #229

patrickfreed added a commit that referenced this issue Jul 8, 2021
This commit also adds support for borrowed deserialization (#231, RUST-688) and fixes RUST-880 and RUST-884.
@patrickfreed
Copy link
Contributor

This is implemented in 7ccf82b and will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracked-in-jira Ticket filed in Mongo's Jira system
Projects
None yet
Development

No branches or pull requests

4 participants