Storage

Trait Storage 

Source
pub trait Storage:
    Debug
    + Send
    + Sync
    + Serialize
    + Deserialize {
    // Required methods
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn metadata<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<FileMetadata>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn read<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn reader<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn FileRead>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn write<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        bs: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn writer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn FileWrite>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_prefix<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_stream<'life0, 'async_trait>(
        &'life0 self,
        paths: BoxStream<'static, String>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn new_input(&self, path: &str) -> Result<InputFile>;
    fn new_output(&self, path: &str) -> Result<OutputFile>;
}
Expand description

Trait for storage operations in Iceberg.

The trait supports serialization via typetag, allowing storage instances to be serialized and deserialized across process boundaries.

Third-party implementations can implement this trait to provide custom storage backends.

§Implementing Custom Storage

To implement a custom storage backend:

  1. Create a struct that implements this trait
  2. Add #[typetag::serde] attribute for serialization support
  3. Implement all required methods

§Example

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
struct MyStorage {
    // custom fields
}

#[async_trait]
#[typetag::serde]
impl Storage for MyStorage {
    async fn exists(&self, path: &str) -> Result<bool> {
        // implementation
        todo!()
    }
    // ... implement other methods
}

Required Methods§

Source

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a file exists at the given path

Source

fn metadata<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<FileMetadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get metadata from an input path

Source

fn read<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read bytes from a path

Source

fn reader<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn FileRead>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get FileRead from a path

Source

fn write<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, bs: Bytes, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write bytes to an output path

Source

fn writer<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn FileWrite>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get FileWrite from a path

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a file at the given path

Source

fn delete_prefix<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete all files with the given prefix

Source

fn delete_stream<'life0, 'async_trait>( &'life0 self, paths: BoxStream<'static, String>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete multiple files from a stream of paths.

Source

fn new_input(&self, path: &str) -> Result<InputFile>

Create a new input file for reading

Source

fn new_output(&self, path: &str) -> Result<OutputFile>

Create a new output file for writing

Trait Implementations§

Source§

impl<'typetag> Serialize for dyn Storage + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Storage + Send + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Storage + Send + Sync + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Storage + Sync + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Implementors§