Skip to content

Commit f41c2a4

Browse files
alambtustvold
andauthored
Minor: add additional documentation about BufWriter (#5519)
* Minor: add additional documentation about BufWriter * Update object_store/src/buffered.rs * Apply suggestions from code review Co-authored-by: Raphael Taylor-Davies <[email protected]> * Format --------- Co-authored-by: Raphael Taylor-Davies <[email protected]> Co-authored-by: Raphael Taylor-Davies <[email protected]>
1 parent 7e5f523 commit f41c2a4

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

object_store/src/buffered.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ impl AsyncBufRead for BufReader {
207207

208208
/// An async buffered writer compatible with the tokio IO traits
209209
///
210+
/// This writer adaptively uses [`ObjectStore::put`] or
211+
/// [`ObjectStore::put_multipart`] depending on the amount of data that has
212+
/// been written.
213+
///
210214
/// Up to `capacity` bytes will be buffered in memory, and flushed on shutdown
211215
/// using [`ObjectStore::put`]. If `capacity` is exceeded, data will instead be
212216
/// streamed using [`ObjectStore::put_multipart`]
@@ -255,7 +259,8 @@ impl BufWriter {
255259
}
256260
}
257261

258-
/// Returns the [`MultipartId`] if multipart upload
262+
/// Returns the [`MultipartId`] of the multipart upload created by this
263+
/// writer, if any.
259264
pub fn multipart_id(&self) -> Option<&MultipartId> {
260265
self.multipart_id.as_ref()
261266
}

object_store/src/lib.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,24 @@
8888
//!
8989
//! # Why not a Filesystem Interface?
9090
//!
91-
//! Whilst this crate does provide a [`BufReader`], the [`ObjectStore`] interface mirrors the APIs
92-
//! of object stores and not filesystems, opting to provide stateless APIs instead of the cursor
93-
//! based interfaces such as [`Read`] or [`Seek`] favoured by filesystems.
91+
//! The [`ObjectStore`] interface is designed to mirror the APIs
92+
//! of object stores and *not* filesystems, and thus has stateless APIs instead
93+
//! of cursor based interfaces such as [`Read`] or [`Seek`] available in filesystems.
9494
//!
95-
//! This provides some compelling advantages:
95+
//! This design provides the following advantages:
9696
//!
9797
//! * All operations are atomic, and readers cannot observe partial and/or failed writes
9898
//! * Methods map directly to object store APIs, providing both efficiency and predictability
9999
//! * Abstracts away filesystem and operating system specific quirks, ensuring portability
100100
//! * Allows for functionality not native to filesystems, such as operation preconditions
101101
//! and atomic multipart uploads
102102
//!
103+
//! This crate does provide [`BufReader`] and [`BufWriter`] adapters
104+
//! which provide a more filesystem-like API for working with the
105+
//! [`ObjectStore`] trait, however, they should be used with care
106+
//!
103107
//! [`BufReader`]: buffered::BufReader
108+
//! [`BufWriter`]: buffered::BufWriter
104109
//!
105110
//! # Adapters
106111
//!

0 commit comments

Comments
 (0)