pub enum ServerObjectStore {
Local(LocalObjectStore),
S3(S3ObjectStore),
Blackhole,
}Expand description
Unified object-store backend that delegates to local, S3, or blackhole storage.
Variants§
Local(LocalObjectStore)
Local filesystem object store.
S3(S3ObjectStore)
S3-compatible object store.
Blackhole
Blackhole object store that discards all writes.
Implementations§
Source§impl ServerObjectStore
impl ServerObjectStore
Sourcepub fn local(
root: impl Into<PathBuf>,
) -> Result<ServerObjectStore, ServerObjectStoreError>
pub fn local( root: impl Into<PathBuf>, ) -> Result<ServerObjectStore, ServerObjectStoreError>
Creates a local filesystem object store rooted at the given path.
§Errors
Returns ServerObjectStoreError::Local if the local store cannot be created.
Sourcepub fn s3(
config: S3ObjectStoreConfig,
) -> Result<ServerObjectStore, ServerObjectStoreError>
pub fn s3( config: S3ObjectStoreConfig, ) -> Result<ServerObjectStore, ServerObjectStoreError>
Creates an S3-compatible object store from the provided configuration.
§Errors
Returns ServerObjectStoreError::S3 if the S3 store cannot be created.
Sourcepub const fn blackhole() -> ServerObjectStore
pub const fn blackhole() -> ServerObjectStore
Creates a blackhole object store that discards all writes.
Sourcepub fn put_overwrite(
&self,
key: &ObjectKey,
body: ObjectBody<'_>,
integrity: &ObjectIntegrity,
) -> Result<(), ServerObjectStoreError>
pub fn put_overwrite( &self, key: &ObjectKey, body: ObjectBody<'_>, integrity: &ObjectIntegrity, ) -> Result<(), ServerObjectStoreError>
Stores an object, overwriting any existing object at the given key.
§Errors
Returns ServerObjectStoreError on storage backend failures.
Sourcepub fn visit_prefix<F, E>(
&self,
prefix: &ObjectPrefix,
visitor: F,
) -> Result<(), E>where
F: FnMut(ObjectMetadata) -> Result<(), E>,
E: From<LocalObjectStoreError> + From<S3ObjectStoreError>,
pub fn visit_prefix<F, E>(
&self,
prefix: &ObjectPrefix,
visitor: F,
) -> Result<(), E>where
F: FnMut(ObjectMetadata) -> Result<(), E>,
E: From<LocalObjectStoreError> + From<S3ObjectStoreError>,
Visits all objects under the given prefix, invoking the visitor for each.
§Errors
Returns any error produced by the visitor or the underlying storage backend.
Sourcepub fn list_flat_namespace_page(
&self,
prefix: &ObjectPrefix,
start_after: Option<&ObjectKey>,
limit: usize,
) -> Result<Vec<ObjectMetadata>, ServerObjectStoreError>
pub fn list_flat_namespace_page( &self, prefix: &ObjectPrefix, start_after: Option<&ObjectKey>, limit: usize, ) -> Result<Vec<ObjectMetadata>, ServerObjectStoreError>
Lists objects under the given prefix with pagination.
§Errors
Returns ServerObjectStoreError on storage backend failures.
Sourcepub fn local_path_for_key(&self, key: &ObjectKey) -> Option<PathBuf>
pub fn local_path_for_key(&self, key: &ObjectKey) -> Option<PathBuf>
Returns the local filesystem path for an object key, if backed by local storage.
Sourcepub fn copy_if_absent(
&self,
source: &ObjectKey,
destination: &ObjectKey,
) -> Result<PutOutcome, ServerObjectStoreError>
pub fn copy_if_absent( &self, source: &ObjectKey, destination: &ObjectKey, ) -> Result<PutOutcome, ServerObjectStoreError>
Copies an object from source to destination if no object exists at the destination.
§Errors
Returns ServerObjectStoreError::NotFound for blackhole stores or
storage backend errors.
Sourcepub fn put_content_addressed_file(
&self,
key: &ObjectKey,
path: &Path,
integrity: &ObjectIntegrity,
) -> Result<PutOutcome, ServerObjectStoreError>
pub fn put_content_addressed_file( &self, key: &ObjectKey, path: &Path, integrity: &ObjectIntegrity, ) -> Result<PutOutcome, ServerObjectStoreError>
Stores a content-addressed file from the local filesystem.
§Errors
Returns ServerObjectStoreError on storage backend failures.
Sourcepub fn local_root(&self) -> Option<&Path>
pub fn local_root(&self) -> Option<&Path>
Returns the local filesystem root, if backed by local storage.
Sourcepub const fn backend_name(&self) -> &'static str
pub const fn backend_name(&self) -> &'static str
Returns the backend name for this object store.
Sourcepub fn read_full_object(
&self,
object_key: &ObjectKey,
length: u64,
) -> Result<Vec<u8>, ServerObjectStoreError>
pub fn read_full_object( &self, object_key: &ObjectKey, length: u64, ) -> Result<Vec<u8>, ServerObjectStoreError>
Reads the full contents of an object from the store.
§Errors
Returns ServerObjectStoreError on storage backend failures, length
mismatches, or arithmetic overflows.
Trait Implementations§
Source§impl Clone for ServerObjectStore
impl Clone for ServerObjectStore
Source§fn clone(&self) -> ServerObjectStore
fn clone(&self) -> ServerObjectStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServerObjectStore
impl Debug for ServerObjectStore
Source§impl ObjectStore for ServerObjectStore
impl ObjectStore for ServerObjectStore
Source§type Error = ServerObjectStoreError
type Error = ServerObjectStoreError
Source§fn put_if_absent(
&self,
key: &ObjectKey,
body: ObjectBody<'_>,
integrity: &ObjectIntegrity,
) -> Result<PutOutcome, <ServerObjectStore as ObjectStore>::Error>
fn put_if_absent( &self, key: &ObjectKey, body: ObjectBody<'_>, integrity: &ObjectIntegrity, ) -> Result<PutOutcome, <ServerObjectStore as ObjectStore>::Error>
Source§fn read_range(
&self,
key: &ObjectKey,
range: ByteRange,
) -> Result<Vec<u8>, <ServerObjectStore as ObjectStore>::Error>
fn read_range( &self, key: &ObjectKey, range: ByteRange, ) -> Result<Vec<u8>, <ServerObjectStore as ObjectStore>::Error>
Source§fn contains(
&self,
key: &ObjectKey,
) -> Result<bool, <ServerObjectStore as ObjectStore>::Error>
fn contains( &self, key: &ObjectKey, ) -> Result<bool, <ServerObjectStore as ObjectStore>::Error>
Source§fn metadata(
&self,
key: &ObjectKey,
) -> Result<Option<ObjectMetadata>, <ServerObjectStore as ObjectStore>::Error>
fn metadata( &self, key: &ObjectKey, ) -> Result<Option<ObjectMetadata>, <ServerObjectStore as ObjectStore>::Error>
Source§fn list_prefix(
&self,
prefix: &ObjectPrefix,
) -> Result<Vec<ObjectMetadata>, <ServerObjectStore as ObjectStore>::Error>
fn list_prefix( &self, prefix: &ObjectPrefix, ) -> Result<Vec<ObjectMetadata>, <ServerObjectStore as ObjectStore>::Error>
Source§fn delete_if_present(
&self,
key: &ObjectKey,
) -> Result<DeleteOutcome, <ServerObjectStore as ObjectStore>::Error>
fn delete_if_present( &self, key: &ObjectKey, ) -> Result<DeleteOutcome, <ServerObjectStore as ObjectStore>::Error>
Source§fn visit_prefix<Visitor, VisitorError>(
&self,
prefix: &ObjectPrefix,
visitor: Visitor,
) -> Result<(), VisitorError>
fn visit_prefix<Visitor, VisitorError>( &self, prefix: &ObjectPrefix, visitor: Visitor, ) -> Result<(), VisitorError>
Auto Trait Implementations§
impl !RefUnwindSafe for ServerObjectStore
impl !UnwindSafe for ServerObjectStore
impl Freeze for ServerObjectStore
impl Send for ServerObjectStore
impl Sync for ServerObjectStore
impl Unpin for ServerObjectStore
impl UnsafeUnpin for ServerObjectStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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