Trait zarrs::storage::ReadableStorageTraits
source · pub trait ReadableStorageTraits: Send + Sync {
// Required methods
fn get(&self, key: &StoreKey) -> Result<MaybeBytes, StorageError>;
fn get_partial_values_key(
&self,
key: &StoreKey,
byte_ranges: &[ByteRange]
) -> Result<Option<Vec<Vec<u8>>>, StorageError>;
fn get_partial_values(
&self,
key_ranges: &[StoreKeyRange]
) -> Result<Vec<MaybeBytes>, StorageError>;
fn size_prefix(&self, prefix: &StorePrefix) -> Result<u64, StorageError>;
fn size_key(&self, key: &StoreKey) -> Result<Option<u64>, StorageError>;
// Provided methods
fn size(&self) -> Result<u64, StorageError> { ... }
fn get_partial_values_batched_by_key(
&self,
key_ranges: &[StoreKeyRange]
) -> Result<Vec<MaybeBytes>, StorageError> { ... }
}
Expand description
Readable storage traits.
Required Methods§
sourcefn get(&self, key: &StoreKey) -> Result<MaybeBytes, StorageError>
fn get(&self, key: &StoreKey) -> Result<MaybeBytes, StorageError>
Retrieve the value (bytes) associated with a given StoreKey
.
Returns None
if the key is not found.
§Errors
Returns a StorageError
if there is an underlying storage error.
sourcefn get_partial_values_key(
&self,
key: &StoreKey,
byte_ranges: &[ByteRange]
) -> Result<Option<Vec<Vec<u8>>>, StorageError>
fn get_partial_values_key( &self, key: &StoreKey, byte_ranges: &[ByteRange] ) -> Result<Option<Vec<Vec<u8>>>, StorageError>
Retrieve partial bytes from a list of byte ranges for a store key.
Returns None
if the key is not found.
§Errors
Returns a StorageError
if there is an underlying storage error.
sourcefn get_partial_values(
&self,
key_ranges: &[StoreKeyRange]
) -> Result<Vec<MaybeBytes>, StorageError>
fn get_partial_values( &self, key_ranges: &[StoreKeyRange] ) -> Result<Vec<MaybeBytes>, StorageError>
Retrieve partial bytes from a list of StoreKeyRange
.
§Arguments
key_ranges
: ordered set of (StoreKey
,ByteRange
) pairs. A key may occur multiple times with different ranges.
§Output
A a list of values in the order of the key_ranges
. It will be None
for missing keys.
§Errors
Returns a StorageError
if there is an underlying storage error.
sourcefn size_prefix(&self, prefix: &StorePrefix) -> Result<u64, StorageError>
fn size_prefix(&self, prefix: &StorePrefix) -> Result<u64, StorageError>
Return the size in bytes of all keys under prefix
.
§Errors
Returns a StorageError
if the store does not support size()
or there is an underlying error with the store.
sourcefn size_key(&self, key: &StoreKey) -> Result<Option<u64>, StorageError>
fn size_key(&self, key: &StoreKey) -> Result<Option<u64>, StorageError>
Return the size in bytes of the value at key
.
Returns None
if the key is not found.
§Errors
Returns a StorageError
if there is an underlying storage error.
Provided Methods§
sourcefn size(&self) -> Result<u64, StorageError>
fn size(&self) -> Result<u64, StorageError>
Return the total size in bytes of the storage.
§Errors
Returns a StorageError
if the store does not support size()
or there is an underlying error with the store.
sourcefn get_partial_values_batched_by_key(
&self,
key_ranges: &[StoreKeyRange]
) -> Result<Vec<MaybeBytes>, StorageError>
fn get_partial_values_batched_by_key( &self, key_ranges: &[StoreKeyRange] ) -> Result<Vec<MaybeBytes>, StorageError>
A utility method with the same input and output as get_partial_values
that internally calls get_partial_values_key
with byte ranges grouped by key.
Readable storage can use this function in the implementation of get_partial_values
if that is optimal.
§Errors
Returns a StorageError
if there is an underlying storage error.
Implementors§
impl ReadableStorageTraits for FilesystemStore
impl ReadableStorageTraits for HTTPStore
http
only.impl ReadableStorageTraits for MemoryStore
impl ReadableStorageTraits for OpendalStore
opendal
only.impl<TStorage: ?Sized + ReadableStorageTraits> ReadableStorageTraits for ZipStorageAdapter<TStorage>
zip
only.