Skip to main content

TableDefinition

Trait TableDefinition 

Source
pub trait TableDefinition {
    type KeySchema: KeySchema;

    // Required method
    fn table_name() -> String;
}
Expand description

Defines a DynamoDB table: its name and key schema.

Implementations are generated by table_definitions!. The associated KeySchema determines whether the table uses a simple or composite key, and which attribute definitions serve as partition and sort keys.

All items, keys, and operation builders are scoped to a specific table through this trait, ensuring you cannot accidentally mix items or keys from different tables.

§Examples

use dynamodb_facade::{table_definitions, TableDefinition};

table_definitions! {
    MyTable {
        type PartitionKey = PK;
        type SortKey = SK;
        fn table_name() -> String { "platform".to_owned() }
    }
}

fn expect_table<TD: TableDefinition>() {}
expect_table::<MyTable>();
assert_eq!(MyTable::table_name(), "platform");

Required Associated Types§

Source

type KeySchema: KeySchema

The key schema for this table.

Required Methods§

Source

fn table_name() -> String

Returns the DynamoDB table name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§