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§

source

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.

source

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.

source

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.

source

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.

source

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§

source

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.

source

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§

source§

impl ReadableStorageTraits for FilesystemStore

source§

impl ReadableStorageTraits for HTTPStore

Available on crate feature http only.
source§

impl ReadableStorageTraits for MemoryStore

source§

impl ReadableStorageTraits for OpendalStore

Available on crate feature opendal only.
source§

impl<TStorage: ?Sized + ReadableStorageTraits> ReadableStorageTraits for ZipStorageAdapter<TStorage>

Available on crate feature zip only.
source§

impl<TStorage: ?Sized + ReadableStorageTraits> ReadableStorageTraits for StorageHandle<TStorage>