pub struct FileStore { /* private fields */ }Expand description
An abstract interface over one or more storage transports.
Supports separate writable and read-only transport pools. Write operations (upload, put, delete) only target writable transports. Read operations (download, get, exists, stream) search both pools, with read-only transports used as a fallback for data that hasn’t been migrated to the primary storage.
Implementations§
Source§impl FileStore
impl FileStore
Sourcepub async fn open(urls: &[String]) -> Result<Arc<FileStore>>
pub async fn open(urls: &[String]) -> Result<Arc<FileStore>>
Open all urls with default parameters
Sourcepub async fn with_limit_retries(url: &str) -> Result<Arc<FileStore>>
pub async fn with_limit_retries(url: &str) -> Result<Arc<FileStore>>
Open a single url with retrying disabled
Sourcepub async fn put(&self, name: &str, body: &Bytes) -> Result<()>
pub async fn put(&self, name: &str, body: &Bytes) -> Result<()>
Upload a buffer to all writable transports. Read-only transports are skipped.
Sourcepub async fn exists(&self, name: &str) -> Result<bool>
pub async fn exists(&self, name: &str) -> Result<bool>
Check if a given blob is defined in any transport (writable or read-only). Errors will be supressed as long as any transport contains the file.
Sourcepub async fn get(&self, name: &str) -> Result<Option<Vec<u8>>>
pub async fn get(&self, name: &str) -> Result<Option<Vec<u8>>>
Pull blob to in memory buffer from any transport (writable or read-only). Returns errors only if all transports fail, otherwise errors will be logged as warnings.
Sourcepub async fn download(&self, name: &str, path: &Path) -> Result<()>
pub async fn download(&self, name: &str, path: &Path) -> Result<()>
Download a blob and write it to a local file from any transport (writable or read-only). If the file does not exist it will be created. If it does exist it will be replaced.
Sourcepub async fn upload(&self, path: &Path, name: &str) -> Result<()>
pub async fn upload(&self, path: &Path, name: &str) -> Result<()>
Upload a local file as a named blob to writable transports only. Read-only transports are skipped.
Sourcepub async fn upload_batch(
&self,
local_remote_tuples: &[(&Path, &str)],
) -> Vec<(PathBuf, String, String)>
pub async fn upload_batch( &self, local_remote_tuples: &[(&Path, &str)], ) -> Vec<(PathBuf, String, String)>
Upload a collection of local files to writable transports only.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileStore
impl !RefUnwindSafe for FileStore
impl Send for FileStore
impl Sync for FileStore
impl Unpin for FileStore
impl UnsafeUnpin for FileStore
impl !UnwindSafe for FileStore
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> 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