pub struct DynamoClient { /* private fields */ }Expand description
DynamoDB client wrapper with integrated VIL semantic logging.
Every operation automatically emits a db_log! entry with:
db_hash— FxHash of"dynamodb"table_hash— FxHash of the table nameduration_ns— Wall-clock time of the operationrows_affected— Items returned/affectedop_type— 0=GET 1=PUT 2=UPDATE 3=DELETE 4=QUERY 5=SCANerror_code— 0 on success, non-zero on fault
Implementations§
Source§impl DynamoClient
impl DynamoClient
Sourcepub async fn new(config: DynamoConfig) -> DynamoResult<Self>
pub async fn new(config: DynamoConfig) -> DynamoResult<Self>
Build a DynamoClient from DynamoConfig.
Loads AWS credentials from the environment / instance profile.
Sourcepub fn raw_client(&self) -> &Client
pub fn raw_client(&self) -> &Client
Access the underlying aws_sdk_dynamodb::Client.
Source§impl DynamoClient
impl DynamoClient
Sourcepub async fn get_item(
&self,
table: &str,
key: HashMap<String, AttributeValue>,
) -> DynamoResult<Option<HashMap<String, AttributeValue>>>
pub async fn get_item( &self, table: &str, key: HashMap<String, AttributeValue>, ) -> DynamoResult<Option<HashMap<String, AttributeValue>>>
Fetch a single item from table by its primary key key.
Returns None if no item matched.
Emits db_log! with op_type = 0 (GET).
Sourcepub async fn put_item(
&self,
table: &str,
item: HashMap<String, AttributeValue>,
) -> DynamoResult<()>
pub async fn put_item( &self, table: &str, item: HashMap<String, AttributeValue>, ) -> DynamoResult<()>
Write item into table, replacing any existing item with the same key.
Emits db_log! with op_type = 1 (PUT).
Sourcepub async fn delete_item(
&self,
table: &str,
key: HashMap<String, AttributeValue>,
) -> DynamoResult<()>
pub async fn delete_item( &self, table: &str, key: HashMap<String, AttributeValue>, ) -> DynamoResult<()>
Delete the item identified by key from table.
Emits db_log! with op_type = 3 (DELETE).
Sourcepub async fn query(
&self,
table: &str,
key_condition: &str,
expr_attr_values: HashMap<String, AttributeValue>,
) -> DynamoResult<Vec<HashMap<String, AttributeValue>>>
pub async fn query( &self, table: &str, key_condition: &str, expr_attr_values: HashMap<String, AttributeValue>, ) -> DynamoResult<Vec<HashMap<String, AttributeValue>>>
Run a Query against table using the given key-condition expression.
Returns a Vec of attribute maps.
Emits db_log! with op_type = 4 (QUERY).
Sourcepub async fn scan(
&self,
table: &str,
filter_expression: Option<&str>,
expr_attr_values: Option<HashMap<String, AttributeValue>>,
) -> DynamoResult<Vec<HashMap<String, AttributeValue>>>
pub async fn scan( &self, table: &str, filter_expression: Option<&str>, expr_attr_values: Option<HashMap<String, AttributeValue>>, ) -> DynamoResult<Vec<HashMap<String, AttributeValue>>>
Scan all items in table, with an optional filter expression.
Returns a Vec of attribute maps.
Emits db_log! with op_type = 5 (SCAN).
Sourcepub async fn update_item(
&self,
table: &str,
key: HashMap<String, AttributeValue>,
update_expression: &str,
expr_attr_values: HashMap<String, AttributeValue>,
) -> DynamoResult<()>
pub async fn update_item( &self, table: &str, key: HashMap<String, AttributeValue>, update_expression: &str, expr_attr_values: HashMap<String, AttributeValue>, ) -> DynamoResult<()>
Update an item in table using an update expression.
Emits db_log! with op_type = 2 (UPDATE).
Auto Trait Implementations§
impl Freeze for DynamoClient
impl !RefUnwindSafe for DynamoClient
impl Send for DynamoClient
impl Sync for DynamoClient
impl Unpin for DynamoClient
impl UnsafeUnpin for DynamoClient
impl !UnwindSafe for DynamoClient
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
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>
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>
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 more