11// Copyright 2026 ExtendDB contributors
22// SPDX-License-Identifier: Apache-2.0
33
4- //! Condition context trait and DynamoDB request context.
4+ //! Condition context trait and ` DynamoDB` request context.
55//!
66//! `ConditionContext` is the shared trait for resolving condition keys during
7- //! policy evaluation. `RequestContext` implements it for DynamoDB operations;
7+ //! policy evaluation. `RequestContext` implements it for ` DynamoDB` operations;
88//! `AssumeRoleContext` implements it for trust policy evaluation.
99
1010use std:: collections:: HashMap ;
1111
1212/// Trait for resolving condition keys during policy evaluation.
1313///
14- /// Implemented by `RequestContext` (DynamoDB operations) and
15- /// `AssumeRoleContext` (trust policy / AssumeRole).
14+ /// Implemented by `RequestContext` (` DynamoDB` operations) and
15+ /// `AssumeRoleContext` (trust policy / ` AssumeRole` ).
1616pub trait ConditionContext {
1717 /// Resolve a condition key to its value(s).
1818 ///
@@ -21,29 +21,29 @@ pub trait ConditionContext {
2121 fn resolve_key ( & self , key : & str ) -> Option < Vec < & str > > ;
2222}
2323
24- /// Request parameters extracted from a DynamoDB operation for condition evaluation.
24+ /// Request parameters extracted from a ` DynamoDB` operation for condition evaluation.
2525#[ derive( Debug , Default ) ]
2626pub struct RequestParams {
2727 /// Partition key values being accessed (for `dynamodb:LeadingKeys`).
28- /// `None` for table-level operations (CreateTable, etc.).
28+ /// `None` for table-level operations (` CreateTable` , etc.).
2929 pub leading_keys : Option < Vec < String > > ,
3030 /// Attribute names being read/written (for `dynamodb:Attributes`).
3131 /// `None` when not applicable.
3232 pub attributes : Option < Vec < String > > ,
3333 /// The Select parameter value (for `dynamodb:Select`).
3434 pub select : Option < String > ,
35- /// The ReturnValues parameter value (for `dynamodb:ReturnValues`).
35+ /// The ` ReturnValues` parameter value (for `dynamodb:ReturnValues`).
3636 pub return_values : Option < String > ,
37- /// The ReturnConsumedCapacity parameter value.
37+ /// The ` ReturnConsumedCapacity` parameter value.
3838 pub return_consumed_capacity : Option < String > ,
3939 /// The enclosing operation for batch/transact sub-operations.
4040 pub enclosing_operation : Option < String > ,
4141}
4242
43- /// Context for evaluating conditions on DynamoDB operations.
43+ /// Context for evaluating conditions on ` DynamoDB` operations.
4444///
4545/// Built by the server middleware before policy evaluation. Contains all
46- /// condition keys that IAM policies can reference for DynamoDB access control.
46+ /// condition keys that IAM policies can reference for ` DynamoDB` access control.
4747#[ derive( Debug ) ]
4848pub struct RequestContext {
4949 /// Tags on the authenticated principal (`aws:PrincipalTag/*`).
@@ -56,9 +56,9 @@ pub struct RequestContext {
5656 pub attributes : Option < Vec < String > > ,
5757 /// The Select parameter value.
5858 pub select : Option < String > ,
59- /// The ReturnValues parameter value.
59+ /// The ` ReturnValues` parameter value.
6060 pub return_values : Option < String > ,
61- /// The ReturnConsumedCapacity parameter value.
61+ /// The ` ReturnConsumedCapacity` parameter value.
6262 pub return_consumed_capacity : Option < String > ,
6363 /// Whether this is a Scan operation.
6464 pub full_table_scan : Option < bool > ,
@@ -67,11 +67,12 @@ pub struct RequestContext {
6767}
6868
6969impl RequestContext {
70- /// Build context for a DynamoDB operation.
70+ /// Build context for a ` DynamoDB` operation.
7171 ///
7272 /// `principal_tags` and `resource_tags` come from the identity and target
7373 /// table respectively. `is_scan` should be true for Scan operations.
7474 /// `params` carries operation-specific request parameters.
75+ #[ must_use]
7576 pub fn build (
7677 principal_tags : HashMap < String , String > ,
7778 resource_tags : HashMap < String , String > ,
@@ -103,11 +104,11 @@ impl ConditionContext for RequestContext {
103104 "dynamodb:LeadingKeys" => self
104105 . leading_keys
105106 . as_ref ( )
106- . map ( |v| v. iter ( ) . map ( |s| s . as_str ( ) ) . collect ( ) ) ,
107+ . map ( |v| v. iter ( ) . map ( std :: string :: String :: as_str) . collect ( ) ) ,
107108 "dynamodb:Attributes" => self
108109 . attributes
109110 . as_ref ( )
110- . map ( |v| v. iter ( ) . map ( |s| s . as_str ( ) ) . collect ( ) ) ,
111+ . map ( |v| v. iter ( ) . map ( std :: string :: String :: as_str) . collect ( ) ) ,
111112 "dynamodb:Select" => self . select . as_deref ( ) . map ( |v| vec ! [ v] ) ,
112113 "dynamodb:ReturnValues" => self . return_values . as_deref ( ) . map ( |v| vec ! [ v] ) ,
113114 "dynamodb:ReturnConsumedCapacity" => {
@@ -125,15 +126,15 @@ impl ConditionContext for RequestContext {
125126 }
126127}
127128
128- /// Context for evaluating trust policy conditions during AssumeRole.
129+ /// Context for evaluating trust policy conditions during ` AssumeRole` .
129130///
130131/// Trust policies can reference `aws:PrincipalTag/*` and `sts:ExternalId`.
131132/// DynamoDB-specific keys are not applicable.
132133#[ derive( Debug ) ]
133134pub struct AssumeRoleContext {
134135 /// Tags on the calling principal.
135136 pub principal_tags : HashMap < String , String > ,
136- /// The external ID provided in the AssumeRole call (if any).
137+ /// The external ID provided in the ` AssumeRole` call (if any).
137138 pub external_id : Option < String > ,
138139}
139140
0 commit comments