dynamodb_expression/condition/attribute_exists.rs
1use core::fmt::{self, Write};
2
3use crate::path::Path;
4/// The [DynamoDB `attribute_exists` function][1]. True if the item contains
5/// the attribute in a specified [`Path`].
6///
7/// See also: [`Path::attribute_exists`]
8///
9/// [1]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
10#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
11pub struct AttributeExists {
12 // `Path` is correct here
13 // https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Syntax
14 pub(crate) path: Path,
15}
16
17impl fmt::Display for AttributeExists {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 f.write_str("attribute_exists(")?;
20 self.path.fmt(f)?;
21 f.write_char(')')
22 }
23}
24
25impl<T> From<T> for AttributeExists
26where
27 T: Into<Path>,
28{
29 fn from(name: T) -> Self {
30 Self { path: name.into() }
31 }
32}