pub trait BucketStore: Send + Sync {
// Required methods
fn prefix(&self) -> &str;
fn writer_id(&self) -> &str;
fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn put_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
path: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn get_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
dest: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn put_if_match<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
etag: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn put_if_not_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_with_etag<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<(Bytes, String)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Bucket-based object storage backend for wal-backup.
§Architecture: one prefix, one owner
Each bucket prefix (e.g. s3://my-bucket/prod-app) belongs to exactly ONE server.
That ownership is recorded in writer.json in the bucket, and verified:
- At
DurabilityLayer::open()— the gate - Every shipper loop iteration — continuous guard
- Every snapshot loop iteration — continuous guard
If another server tries to open the same prefix, it gets Error::WrongWriter.
The bucket is NOT a replication bus. It’s a backup. The pattern is:
Server A → writes to s3://bucket/server-a-prefix (A's backup)
Server B → writes to s3://bucket/server-b-prefix (B's backup)If you need data from another server’s prefix, use wal-backup restore
to a separate location. Don’t share prefixes between servers.
Trait for S3-compatible object storage backends.
Each BucketStore is scoped to a single prefix (e.g. "my-app").
One prefix = one server. The bucket is NOT a replication bus.
Implementations: ObjectStoreBucket, CompressedBucketStore (feature),
EncryptedBucketStore (feature), InMemoryStore (tests only).
Required Methods§
Sourcefn prefix(&self) -> &str
fn prefix(&self) -> &str
The bucket prefix this store is scoped to (e.g. “my-app/db1”). Each prefix has exactly one owner — see module docs.
Sourcefn writer_id(&self) -> &str
fn writer_id(&self) -> &str
Identity of this writer. Stored in writer.json in the bucket. Verified on open and every background loop iteration. If another server tries to use this prefix, they get Error::WrongWriter.
fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn put_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
path: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
path: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream a local file to object storage. Avoids loading the entire file into memory, making it safe for large database snapshots.
Sourcefn get_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
dest: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
dest: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream from object storage directly to a local file. Avoids loading the entire object into memory. Returns the file path on success.
Sourcefn put_if_match<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
etag: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put_if_match<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
etag: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Put data with an ETag precondition. Fails with PreconditionFailed if the
object’s current ETag does not match etag. This enables optimistic
concurrency control for manifest writes.
Sourcefn put_if_not_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put_if_not_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Atomically create an object only if it does not already exist.
Returns Ok(()) if created, Err(Error::PreconditionFailed) if already exists.
This is the key primitive for acquiring distributed locks.
Sourcefn get_with_etag<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<(Bytes, String)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_with_etag<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<(Bytes, String)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Internal: get object data and its ETag. Used to populate manifest.etag after reading the manifest from bucket.
Note: this loads the full object into memory via bytes().await.
This is acceptable because it’s only used for the manifest (small JSON),
not for large snapshots (which use get_file() for streaming).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".