pub struct ObjectStore {
pub inner: Arc<dyn OSObjectStore>,
pub use_constant_size_upload_parts: bool,
pub list_is_lexically_ordered: bool,
/* private fields */
}
Expand description
Wraps ObjectStore
Fields§
§inner: Arc<dyn OSObjectStore>
§use_constant_size_upload_parts: bool
Whether to use constant size upload parts for multipart uploads. This is only necessary for Cloudflare R2.
list_is_lexically_ordered: bool
Whether we can assume that the list of files is lexically ordered. This is true for object stores, but not for local filesystems.
Implementations§
Source§impl ObjectStore
impl ObjectStore
Sourcepub async fn from_uri(uri: &str) -> Result<(Self, Path)>
pub async fn from_uri(uri: &str) -> Result<(Self, Path)>
Parse from a string URI.
Returns the ObjectStore instance and the absolute path to the object.
Sourcepub async fn from_uri_and_params(
registry: Arc<ObjectStoreRegistry>,
uri: &str,
params: &ObjectStoreParams,
) -> Result<(Self, Path)>
pub async fn from_uri_and_params( registry: Arc<ObjectStoreRegistry>, uri: &str, params: &ObjectStoreParams, ) -> Result<(Self, Path)>
Parse from a string URI.
Returns the ObjectStore instance and the absolute path to the object.
pub fn from_path_with_scheme( str_path: &str, scheme: &str, ) -> Result<(Self, Path)>
pub fn from_path(str_path: &str) -> Result<(Self, Path)>
Sourcepub fn is_local(&self) -> bool
pub fn is_local(&self) -> bool
Returns true if the object store pointed to a local file system.
pub fn is_cloud(&self) -> bool
pub fn block_size(&self) -> usize
pub fn set_block_size(&mut self, new_size: usize)
pub fn set_io_parallelism(&mut self, io_parallelism: usize)
pub fn io_parallelism(&self) -> usize
Sourcepub async fn open(&self, path: &Path) -> Result<Box<dyn Reader>>
pub async fn open(&self, path: &Path) -> Result<Box<dyn Reader>>
Open a file for path.
Parameters
path
: Absolute path to the file.
Sourcepub async fn open_with_size(
&self,
path: &Path,
known_size: usize,
) -> Result<Box<dyn Reader>>
pub async fn open_with_size( &self, path: &Path, known_size: usize, ) -> Result<Box<dyn Reader>>
Open a reader for a file with known size.
This size may either have been retrieved from a list operation or cached metadata. By passing in the known size, we can skip a HEAD / metadata call.
Sourcepub async fn create_local_writer(path: &Path) -> Result<ObjectWriter>
pub async fn create_local_writer(path: &Path) -> Result<ObjectWriter>
Create an ObjectWriter from local std::path::Path
Sourcepub async fn open_local(path: &Path) -> Result<Box<dyn Reader>>
pub async fn open_local(path: &Path) -> Result<Box<dyn Reader>>
Open an Reader from local std::path::Path
Sourcepub async fn create(&self, path: &Path) -> Result<ObjectWriter>
pub async fn create(&self, path: &Path) -> Result<ObjectWriter>
Create a new file.
Sourcepub async fn put(&self, path: &Path, content: &[u8]) -> Result<()>
pub async fn put(&self, path: &Path, content: &[u8]) -> Result<()>
A helper function to create a file and write content to it.
pub async fn delete(&self, path: &Path) -> Result<()>
pub async fn copy(&self, from: &Path, to: &Path) -> Result<()>
Sourcepub async fn read_dir(&self, dir_path: impl Into<Path>) -> Result<Vec<String>>
pub async fn read_dir(&self, dir_path: impl Into<Path>) -> Result<Vec<String>>
Read a directory (start from base directory) and returns all sub-paths in the directory.
Sourcepub async fn read_dir_all(
&self,
dir_path: impl Into<&Path> + Send,
unmodified_since: Option<DateTime<Utc>>,
) -> Result<BoxStream<'_, Result<ObjectMeta>>>
pub async fn read_dir_all( &self, dir_path: impl Into<&Path> + Send, unmodified_since: Option<DateTime<Utc>>, ) -> Result<BoxStream<'_, Result<ObjectMeta>>>
Read all files (start from base directory) recursively
unmodified_since can be specified to only return files that have not been modified since the given time.
Sourcepub async fn remove_dir_all(&self, dir_path: impl Into<Path>) -> Result<()>
pub async fn remove_dir_all(&self, dir_path: impl Into<Path>) -> Result<()>
Remove a directory recursively.
pub fn remove_stream<'a>( &'a self, locations: BoxStream<'a, Result<Path>>, ) -> BoxStream<'a, Result<Path>>
Sourcepub async fn read_one_all(&self, path: &Path) -> Result<Bytes>
pub async fn read_one_all(&self, path: &Path) -> Result<Bytes>
Convenience function to open a reader and read all the bytes
Sourcepub async fn read_one_range(
&self,
path: &Path,
range: Range<usize>,
) -> Result<Bytes>
pub async fn read_one_range( &self, path: &Path, range: Range<usize>, ) -> Result<Bytes>
Convenience function open a reader and make a single request
If you will be making multiple requests to the path it is more efficient to call Self::open
and then call Reader::get_range
multiple times.
Trait Implementations§
Source§impl Clone for ObjectStore
impl Clone for ObjectStore
Source§fn clone(&self) -> ObjectStore
fn clone(&self) -> ObjectStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ObjectStore
impl Debug for ObjectStore
Source§impl DeepSizeOf for ObjectStore
impl DeepSizeOf for ObjectStore
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§fn deep_size_of(&self) -> usize
fn deep_size_of(&self) -> usize
Auto Trait Implementations§
impl Freeze for ObjectStore
impl !RefUnwindSafe for ObjectStore
impl Send for ObjectStore
impl Sync for ObjectStore
impl Unpin for ObjectStore
impl !UnwindSafe for ObjectStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more