pub trait StorageBackend {
Show 64 methods
// Required methods
fn clock(&self) -> &dyn Clock;
async fn insert_table_metadata(
&self,
m: &CreateTableMetadata<'_>,
) -> Result<(), BackendError>;
async fn get_table_metadata(
&self,
table_name: &str,
) -> Result<Option<TableMetadata>, BackendError>;
async fn delete_table_metadata(
&self,
table_name: &str,
) -> Result<bool, BackendError>;
async fn update_table_metadata(
&self,
table_name: &str,
attribute_definitions: &str,
gsi_definitions: Option<&str>,
) -> Result<(), BackendError>;
async fn update_provisioned_throughput(
&self,
table_name: &str,
provisioned_throughput: &str,
) -> Result<(), BackendError>;
async fn clear_provisioned_throughput(
&self,
table_name: &str,
) -> Result<(), BackendError>;
async fn update_billing_mode(
&self,
table_name: &str,
billing_mode: &str,
) -> Result<(), BackendError>;
async fn update_table_class(
&self,
table_name: &str,
table_class: &str,
) -> Result<(), BackendError>;
async fn update_on_demand_throughput(
&self,
table_name: &str,
on_demand_throughput: &str,
) -> Result<(), BackendError>;
async fn get_tags(&self, table_name: &str) -> Result<Vec<Tag>, BackendError>;
async fn set_tags(
&self,
table_name: &str,
new_tags: &[Tag],
) -> Result<(), BackendError>;
async fn update_deletion_protection(
&self,
table_name: &str,
enabled: bool,
) -> Result<(), BackendError>;
async fn remove_tags(
&self,
table_name: &str,
keys: &[String],
) -> Result<(), BackendError>;
async fn list_table_names(&self) -> Result<Vec<String>, BackendError>;
async fn table_exists(&self, table_name: &str) -> Result<bool, BackendError>;
async fn create_data_table(
&self,
table_name: &str,
) -> Result<(), BackendError>;
async fn drop_data_table(
&self,
table_name: &str,
) -> Result<(), BackendError>;
async fn create_gsi_table(
&self,
table_name: &str,
index_name: &str,
) -> Result<(), BackendError>;
async fn drop_gsi_table(
&self,
table_name: &str,
index_name: &str,
) -> Result<(), BackendError>;
async fn create_lsi_table(
&self,
table_name: &str,
index_name: &str,
) -> Result<(), BackendError>;
async fn drop_lsi_table(
&self,
table_name: &str,
index_name: &str,
) -> Result<(), BackendError>;
async fn insert_gsi_item(
&self,
table_name: &str,
index_name: &str,
gsi_pk: &str,
gsi_sk: &str,
table_pk: &str,
table_sk: &str,
item_json: &str,
) -> Result<(), BackendError>;
async fn insert_gsi_items(
&self,
table_name: &str,
index_name: &str,
rows: &[GsiItemRow],
) -> Result<(), BackendError>;
async fn delete_gsi_item(
&self,
table_name: &str,
index_name: &str,
table_pk: &str,
table_sk: &str,
) -> Result<(), BackendError>;
async fn query_gsi_items(
&self,
table_name: &str,
index_name: &str,
gsi_pk: &str,
params: &QueryParams<'_>,
) -> Result<Vec<(String, String, String)>, BackendError>;
async fn scan_gsi_items(
&self,
table_name: &str,
index_name: &str,
params: &ScanParams<'_>,
) -> Result<Vec<(String, String, String)>, BackendError>;
async fn insert_lsi_item(
&self,
table_name: &str,
index_name: &str,
pk: &str,
sk: &str,
base_pk: &str,
base_sk: &str,
item_json: &str,
) -> Result<(), BackendError>;
async fn delete_lsi_item(
&self,
table_name: &str,
index_name: &str,
base_pk: &str,
base_sk: &str,
) -> Result<(), BackendError>;
async fn query_lsi_items(
&self,
table_name: &str,
index_name: &str,
pk: &str,
params: &QueryParams<'_>,
) -> Result<Vec<(String, String, String)>, BackendError>;
async fn scan_lsi_items(
&self,
table_name: &str,
index_name: &str,
params: &ScanParams<'_>,
) -> Result<Vec<(String, String, String)>, BackendError>;
async fn begin_transaction(&self) -> Result<(), BackendError>;
async fn commit(&self) -> Result<(), BackendError>;
async fn rollback(&self) -> Result<(), BackendError>;
async fn enable_bulk_loading(&self) -> Result<(), BackendError>;
async fn disable_bulk_loading(&self) -> Result<(), BackendError>;
async fn put_item(
&self,
table_name: &str,
pk: &str,
sk: &str,
item_json: &str,
item_size: usize,
) -> Result<Option<String>, BackendError>;
async fn put_item_with_hash(
&self,
table_name: &str,
pk: &str,
sk: &str,
item_json: &str,
item_size: usize,
hash_prefix: &str,
) -> Result<Option<String>, BackendError>;
async fn put_base_items(
&self,
table_name: &str,
rows: &[BaseItemRow],
) -> Result<(), BackendError>;
async fn get_item(
&self,
table_name: &str,
pk: &str,
sk: &str,
) -> Result<Option<String>, BackendError>;
async fn get_partition_size(
&self,
table_name: &str,
pk: &str,
) -> Result<i64, BackendError>;
async fn get_lsi_partition_size(
&self,
table_name: &str,
index_name: &str,
pk: &str,
) -> Result<i64, BackendError>;
async fn delete_item(
&self,
table_name: &str,
pk: &str,
sk: &str,
) -> Result<Option<String>, BackendError>;
async fn query_items(
&self,
table_name: &str,
pk: &str,
params: &QueryParams<'_>,
) -> Result<Vec<(String, String, String)>, BackendError>;
async fn scan_items(
&self,
table_name: &str,
params: &ScanParams<'_>,
) -> Result<Vec<(String, String, String)>, BackendError>;
async fn count_items(&self, table_name: &str) -> Result<i64, BackendError>;
async fn db_size_bytes(&self) -> Result<u64, BackendError>;
async fn table_count(&self) -> Result<usize, BackendError>;
async fn table_stats(&self) -> Result<Vec<TableStats>, BackendError>;
async fn database_info(&self) -> Result<DatabaseInfo, BackendError>;
async fn vacuum(&self) -> Result<(), BackendError>;
async fn enable_stream(
&self,
table_name: &str,
view_type: &str,
label: &str,
) -> Result<(), BackendError>;
async fn disable_stream(&self, table_name: &str) -> Result<(), BackendError>;
async fn insert_stream_record(
&self,
table_name: &str,
event_name: &str,
keys_json: &str,
new_image: Option<&str>,
old_image: Option<&str>,
sequence_number: &str,
shard_id: &str,
created_at: i64,
) -> Result<(), BackendError>;
async fn insert_stream_record_with_identity(
&self,
table_name: &str,
event_name: &str,
keys_json: &str,
new_image: Option<&str>,
old_image: Option<&str>,
sequence_number: &str,
shard_id: &str,
created_at: i64,
user_identity: Option<&str>,
) -> Result<(), BackendError>;
async fn next_stream_sequence_number(
&self,
table_name: &str,
) -> Result<i64, BackendError>;
async fn get_stream_records(
&self,
table_name: &str,
shard_id: &str,
after_sequence: i64,
limit: usize,
) -> Result<Vec<StreamRecord>, BackendError>;
async fn list_stream_enabled_tables(
&self,
) -> Result<Vec<TableMetadata>, BackendError>;
async fn update_ttl_config(
&self,
table_name: &str,
attribute_name: Option<&str>,
enabled: bool,
) -> Result<(), BackendError>;
async fn list_ttl_enabled_tables(
&self,
) -> Result<Vec<TableMetadata>, BackendError>;
async fn get_shard_sequence_range(
&self,
table_name: &str,
shard_id: &str,
) -> Result<(Option<String>, Option<String>), BackendError>;
async fn touch_cached_at(
&self,
table_name: &str,
pk: &str,
sk: &str,
timestamp: f64,
) -> Result<(), BackendError>;
async fn get_lru_items(
&self,
table_name: &str,
limit: usize,
) -> Result<Vec<(String, String, i64)>, BackendError>;
// Provided method
async fn apply_index_writes(
&self,
ops: &[IndexWriteOp],
) -> Result<(), BackendError> { ... }
}Expand description
Backend-neutral storage interface.
Method signatures mirror Storage’s public
surface 1:1, with three mechanical transformations:
Result<T, DynoxideError>becomesResult<T, BackendError>.fnbecomesasync fn.- Filesystem-typed and rusqlite-typed methods are excluded; they remain
on the native
Storageonly.
The trait is not consumed dynamically today. The native
Storage and the wasm
WasmBridgeBackend each implement it
monomorphically.
The #[allow(async_fn_in_trait)] reflects the monomorphic-only consumption
model. The lint can be revisited if and when dyn StorageBackend becomes
a real callsite.
Required Methods§
Sourcefn clock(&self) -> &dyn Clock
fn clock(&self) -> &dyn Clock
Wall-clock access for the stream and TTL paths.
Sync because reading the clock is not I/O. The native backend returns
its injected Clock; the wasm SQLite backend supplies its own.
async fn insert_table_metadata( &self, m: &CreateTableMetadata<'_>, ) -> Result<(), BackendError>
async fn get_table_metadata( &self, table_name: &str, ) -> Result<Option<TableMetadata>, BackendError>
async fn delete_table_metadata( &self, table_name: &str, ) -> Result<bool, BackendError>
async fn update_table_metadata( &self, table_name: &str, attribute_definitions: &str, gsi_definitions: Option<&str>, ) -> Result<(), BackendError>
async fn update_provisioned_throughput( &self, table_name: &str, provisioned_throughput: &str, ) -> Result<(), BackendError>
async fn clear_provisioned_throughput( &self, table_name: &str, ) -> Result<(), BackendError>
async fn update_billing_mode( &self, table_name: &str, billing_mode: &str, ) -> Result<(), BackendError>
async fn update_table_class( &self, table_name: &str, table_class: &str, ) -> Result<(), BackendError>
async fn update_on_demand_throughput( &self, table_name: &str, on_demand_throughput: &str, ) -> Result<(), BackendError>
async fn update_deletion_protection( &self, table_name: &str, enabled: bool, ) -> Result<(), BackendError>
async fn list_table_names(&self) -> Result<Vec<String>, BackendError>
async fn table_exists(&self, table_name: &str) -> Result<bool, BackendError>
async fn create_data_table(&self, table_name: &str) -> Result<(), BackendError>
async fn drop_data_table(&self, table_name: &str) -> Result<(), BackendError>
async fn create_gsi_table( &self, table_name: &str, index_name: &str, ) -> Result<(), BackendError>
async fn drop_gsi_table( &self, table_name: &str, index_name: &str, ) -> Result<(), BackendError>
async fn create_lsi_table( &self, table_name: &str, index_name: &str, ) -> Result<(), BackendError>
async fn drop_lsi_table( &self, table_name: &str, index_name: &str, ) -> Result<(), BackendError>
async fn insert_gsi_item( &self, table_name: &str, index_name: &str, gsi_pk: &str, gsi_sk: &str, table_pk: &str, table_sk: &str, item_json: &str, ) -> Result<(), BackendError>
Sourceasync fn insert_gsi_items(
&self,
table_name: &str,
index_name: &str,
rows: &[GsiItemRow],
) -> Result<(), BackendError>
async fn insert_gsi_items( &self, table_name: &str, index_name: &str, rows: &[GsiItemRow], ) -> Result<(), BackendError>
Bulk-insert many rows into one GSI table.
Batch-shaped so a backend can amortise per-row round-trips (the native
backend reuses a single cached prepared statement). Used by the GSI
backfill path; the per-row insert_gsi_item
covers single writes during normal fan-out.
async fn delete_gsi_item( &self, table_name: &str, index_name: &str, table_pk: &str, table_sk: &str, ) -> Result<(), BackendError>
async fn query_gsi_items( &self, table_name: &str, index_name: &str, gsi_pk: &str, params: &QueryParams<'_>, ) -> Result<Vec<(String, String, String)>, BackendError>
async fn scan_gsi_items( &self, table_name: &str, index_name: &str, params: &ScanParams<'_>, ) -> Result<Vec<(String, String, String)>, BackendError>
async fn insert_lsi_item( &self, table_name: &str, index_name: &str, pk: &str, sk: &str, base_pk: &str, base_sk: &str, item_json: &str, ) -> Result<(), BackendError>
async fn delete_lsi_item( &self, table_name: &str, index_name: &str, base_pk: &str, base_sk: &str, ) -> Result<(), BackendError>
async fn query_lsi_items( &self, table_name: &str, index_name: &str, pk: &str, params: &QueryParams<'_>, ) -> Result<Vec<(String, String, String)>, BackendError>
async fn scan_lsi_items( &self, table_name: &str, index_name: &str, params: &ScanParams<'_>, ) -> Result<Vec<(String, String, String)>, BackendError>
async fn begin_transaction(&self) -> Result<(), BackendError>
async fn commit(&self) -> Result<(), BackendError>
async fn rollback(&self) -> Result<(), BackendError>
async fn enable_bulk_loading(&self) -> Result<(), BackendError>
async fn disable_bulk_loading(&self) -> Result<(), BackendError>
async fn put_item( &self, table_name: &str, pk: &str, sk: &str, item_json: &str, item_size: usize, ) -> Result<Option<String>, BackendError>
async fn put_item_with_hash( &self, table_name: &str, pk: &str, sk: &str, item_json: &str, item_size: usize, hash_prefix: &str, ) -> Result<Option<String>, BackendError>
Sourceasync fn put_base_items(
&self,
table_name: &str,
rows: &[BaseItemRow],
) -> Result<(), BackendError>
async fn put_base_items( &self, table_name: &str, rows: &[BaseItemRow], ) -> Result<(), BackendError>
Bulk-insert many base-table rows in one call (INSERT OR REPLACE).
Batch-shaped so a backend can amortise per-row round-trips (the native
backend reuses a single cached prepared statement). Used by the import
path. Writes cached_at verbatim from each BaseItemRow; see the
note there for how this differs from
put_item_with_hash.
async fn get_item( &self, table_name: &str, pk: &str, sk: &str, ) -> Result<Option<String>, BackendError>
async fn get_partition_size( &self, table_name: &str, pk: &str, ) -> Result<i64, BackendError>
async fn get_lsi_partition_size( &self, table_name: &str, index_name: &str, pk: &str, ) -> Result<i64, BackendError>
async fn delete_item( &self, table_name: &str, pk: &str, sk: &str, ) -> Result<Option<String>, BackendError>
async fn query_items( &self, table_name: &str, pk: &str, params: &QueryParams<'_>, ) -> Result<Vec<(String, String, String)>, BackendError>
async fn scan_items( &self, table_name: &str, params: &ScanParams<'_>, ) -> Result<Vec<(String, String, String)>, BackendError>
async fn count_items(&self, table_name: &str) -> Result<i64, BackendError>
async fn db_size_bytes(&self) -> Result<u64, BackendError>
async fn table_count(&self) -> Result<usize, BackendError>
async fn table_stats(&self) -> Result<Vec<TableStats>, BackendError>
async fn database_info(&self) -> Result<DatabaseInfo, BackendError>
async fn vacuum(&self) -> Result<(), BackendError>
async fn enable_stream( &self, table_name: &str, view_type: &str, label: &str, ) -> Result<(), BackendError>
async fn disable_stream(&self, table_name: &str) -> Result<(), BackendError>
async fn insert_stream_record( &self, table_name: &str, event_name: &str, keys_json: &str, new_image: Option<&str>, old_image: Option<&str>, sequence_number: &str, shard_id: &str, created_at: i64, ) -> Result<(), BackendError>
async fn insert_stream_record_with_identity( &self, table_name: &str, event_name: &str, keys_json: &str, new_image: Option<&str>, old_image: Option<&str>, sequence_number: &str, shard_id: &str, created_at: i64, user_identity: Option<&str>, ) -> Result<(), BackendError>
async fn next_stream_sequence_number( &self, table_name: &str, ) -> Result<i64, BackendError>
async fn get_stream_records( &self, table_name: &str, shard_id: &str, after_sequence: i64, limit: usize, ) -> Result<Vec<StreamRecord>, BackendError>
async fn list_stream_enabled_tables( &self, ) -> Result<Vec<TableMetadata>, BackendError>
async fn update_ttl_config( &self, table_name: &str, attribute_name: Option<&str>, enabled: bool, ) -> Result<(), BackendError>
async fn list_ttl_enabled_tables( &self, ) -> Result<Vec<TableMetadata>, BackendError>
async fn get_shard_sequence_range( &self, table_name: &str, shard_id: &str, ) -> Result<(Option<String>, Option<String>), BackendError>
async fn touch_cached_at( &self, table_name: &str, pk: &str, sk: &str, timestamp: f64, ) -> Result<(), BackendError>
async fn get_lru_items( &self, table_name: &str, limit: usize, ) -> Result<Vec<(String, String, i64)>, BackendError>
Provided Methods§
Sourceasync fn apply_index_writes(
&self,
ops: &[IndexWriteOp],
) -> Result<(), BackendError>
async fn apply_index_writes( &self, ops: &[IndexWriteOp], ) -> Result<(), BackendError>
Apply an ordered batch of GSI/LSI write operations.
The GSI/LSI maintenance helpers build the list and call this once per fan-out instead of invoking the per-item methods one at a time. The default impl replays each op through the matching per-item method in order, so a backend that does not override it behaves exactly as the per-op loop did. The wasm backend overrides this to issue the whole list in a single bridge crossing.
Owns no transaction: the caller’s open transaction supplies atomicity, so a mid-batch failure is rolled back by that caller. An empty list does no work.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".