Skip to main content

AttributeDefinition

Trait AttributeDefinition 

Source
pub trait AttributeDefinition {
    type Type: AttributeType + AttributeValueRef;

    const NAME: &'static str;
}
Expand description

Defines the name and type of a single DynamoDB attribute at the type level.

Implementations are generated by attribute_definitions!. Each implementing type is a zero-sized struct that carries:

These types serve as type-safe identifiers that connect attribute names and DynamoDB types to your key schemas, item definitions, and query builders.

§Examples

use dynamodb_facade::{attribute_definitions, has_attributes, AttributeDefinition, StringAttribute};

attribute_definitions! {
    CourseId { "course_id": StringAttribute }
}


// Use with the has_attributes! or dynamodb_item! macros:
struct MyItem;
has_attributes! {
    MyItem {
        CourseId { const VALUE: &'static str = "COURSE1234"; }
    }
}

// Access the attribute name.
assert_eq!(CourseId::NAME, "course_id");

Required Associated Constants§

Source

const NAME: &'static str

The DynamoDB attribute name (e.g. "PK", "email").

Required Associated Types§

Source

type Type: AttributeType + AttributeValueRef

The DynamoDB scalar type: StringAttribute, NumberAttribute, or BinaryAttribute.

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§