pub struct KeyId<PkId, SkId> { /* private fields */ }Expand description
Type-safe builder for a DynamoDB partition key + sort key pair.
KeyId<PkId, SkId> holds the logical identifiers used to construct a
Key<TD> for a specific item. The type parameters encode
which key components are present:
PkId | SkId | Meaning |
|---|---|---|
NoId | NoId | Both keys are constants — use KeyId::NONE |
T | NoId | Variable PK, constant SK — use KeyId::pk |
T | U | Both keys are variable — use KeyId::pk.sk |
The concrete PkId and SkId types are determined by the item type’s
HasAttribute impls. For example, a User whose PK is derived from a
&str user ID has KeyId<&str, NoId>.
§Examples
Singleton item (constant PK + SK):
use dynamodb_facade::{DynamoDBItemOp, KeyId};
// PlatformConfig has const PK and SK — use KeyId::NONE.
let config = PlatformConfig::get(client, KeyId::NONE).await?;Variable PK, constant SK:
use dynamodb_facade::{DynamoDBItemOp, KeyId};
// User has a PK and a const SK.
let user = User::get(client, KeyId::pk("user-1")).await?;Variable PK + variable SK:
use dynamodb_facade::{DynamoDBItemOp, KeyId};
// Enrollment has a PK and a SK.
let user_enrollment = Enrollment::get(client, KeyId::pk("user-1").sk("course-42")).await?;Implementations§
Source§impl<PkId> KeyId<PkId, NoId>
impl<PkId> KeyId<PkId, NoId>
Sourcepub fn sk<SkId>(self, sk: SkId) -> KeyId<PkId, SkId>
pub fn sk<SkId>(self, sk: SkId) -> KeyId<PkId, SkId>
Adds a sort key ID to produce a composite KeyId<PkId, SkId>.
Use this for item types where both PK and SK are variable.
§Examples
use dynamodb_facade::KeyId;
let key_id: KeyId<&str, &str> = KeyId::pk("user-1").sk("course-42");Trait Implementations§
impl<PkId: Copy, SkId: Copy> Copy for KeyId<PkId, SkId>
Auto Trait Implementations§
impl<PkId, SkId> Freeze for KeyId<PkId, SkId>
impl<PkId, SkId> RefUnwindSafe for KeyId<PkId, SkId>where
PkId: RefUnwindSafe,
SkId: RefUnwindSafe,
impl<PkId, SkId> Send for KeyId<PkId, SkId>
impl<PkId, SkId> Sync for KeyId<PkId, SkId>
impl<PkId, SkId> Unpin for KeyId<PkId, SkId>
impl<PkId, SkId> UnsafeUnpin for KeyId<PkId, SkId>where
PkId: UnsafeUnpin,
SkId: UnsafeUnpin,
impl<PkId, SkId> UnwindSafe for KeyId<PkId, SkId>where
PkId: UnwindSafe,
SkId: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.