Skip to main content

IndexDefinition

Trait IndexDefinition 

Source
pub trait IndexDefinition<TD: TableDefinition> {
    type KeySchema: KeySchema;

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

Defines a DynamoDB Global Secondary Index (GSI) or Local Secondary Index (GSI) on a specific table.

Implementations are generated by index_definitions!. Each index is associated with a parent table and has its own KeySchema describing the index’s partition (and optional sort) key.

Index types are used as turbofish parameters on query methods such as T::query_index::<MyIndex>(client, key_condition).

§Examples

use dynamodb_facade::{index_definitions, IndexDefinition};

index_definitions! {
    #[table = PlatformTable]
    MyIndex {
        type PartitionKey = ItemType;
        fn index_name() -> String { "iCustomIndex".to_owned() }
    }
}

fn expect_index<TD: IndexDefinition<PlatformTable>>() {}
expect_index::<MyIndex>();
assert_eq!(MyIndex::index_name(), "iCustomIndex");

Required Associated Types§

Source

type KeySchema: KeySchema

The key schema for this index.

Required Methods§

Source

fn index_name() -> String

Returns the DynamoDB index name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§