-
Notifications
You must be signed in to change notification settings - Fork 183
RUST-1871 Convert gridfs to a fluent API #1051
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to omit the versions of the upload/download methods that accept a stream - while the spec has both, IMO in the case of Rust it's both unidiomatic and unnecessary.
I think this should be fine, but I'm going to post something in dbx-devs to double check we're not breaking any big rules by doing this -- the spec mentions a few times that both APIs are required. It also seems like we have a decent number of people using gridfs based on issues/bug reports, so I'm not sure if we'll be upsetting anyone by removing half of the gridfs API. But the prereleases will hopefully give us some indication of that.
Thought about this more and I think we should keep both APIs. |
I don't think that's accurate 🙂 While the gridfs For example, const BUF_SIZE: usize = 8192;
while let Some(gridfs_chunk) = source.next_chunk() {
for write_buf in gridfs_chunk.chunks(BUF_SIZE) {
dest.write(write_buf);
}
} * This can be tweaked by the user if needed by creating their own |
Ah I wasn't aware of |
Good thought, added notes to those docs about |
Co-authored-by: Isabel Atkinson <isabelatkinson@gmail.com>
16af04d
to
1eb1025
Compare
RUST-1871
I opted to omit the versions of the upload/download methods that accept a stream - while the spec has both, IMO in the case of Rust it's both unidiomatic and unnecessary. For simple cases
write_all
/read_to_end
does the same thing, and for the more general case it's covered byfutures_util::io::copy
.Also, previously
open_upload_stream
was both non-async and infallible; I think that was an incident of implementation rather than an API guarantee we want to uphold, so I've made it consistent withopen_download_stream
.