pub struct TableInfo {
pub table_name: String,
pub pk: TableAttr,
pub sk: Option<TableAttr>,
pub attrs: Vec<TableAttr>,
pub gsis: Vec<TableGsi>,
pub lsis: Vec<TableLsi>,
pub throughput: Option<Throughput>,
pub seed_data_file: Option<String>,
}Expand description
Defines the detailed schema for a single DynamoDB table.
Used within the tables list in TableConfig.
Fields§
§table_name: StringThe base name of the table. A unique ID will be appended
by the connector upon creation (e.g., my_table becomes my_table-unique_id).
This base name is used to retrieve the actual table name later.
pk: TableAttrThe primary partition key attribute definition.
sk: Option<TableAttr>Optional primary sort key attribute definition.
attrs: Vec<TableAttr>Additional attribute definitions beyond the primary keys. PK and SK attributes are automatically included, no need to repeat here.
gsis: Vec<TableGsi>Global Secondary Index definitions.
lsis: Vec<TableLsi>Local Secondary Index definitions.
throughput: Option<Throughput>Optional provisioned throughput settings. If None, uses Pay-Per-Request billing.
seed_data_file: Option<String>Optional path to a JSON file containing an array of items to seed into the table after creation.
Implementations§
Source§impl TableInfo
impl TableInfo
Sourcepub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Loads TableInfo directly from a YAML file.
Generally, it’s preferred to load the full TableConfig.
§Errors
Returns Err if the file cannot be read (DynamoToolsError::ConfigRead)
or if the YAML content cannot be parsed (DynamoToolsError::ConfigParse).
Sourcepub fn load(s: &str) -> Result<Self>
pub fn load(s: &str) -> Result<Self>
Loads TableInfo directly from a YAML string.
§Errors
Returns Err if the YAML string cannot be parsed (DynamoToolsError::ConfigParse).
§Example
use dynamodb_tools::{TableInfo, AttrType};
let yaml_data = r#"
table_name: my_simple_table
pk:
name: item_id
type: S
"#;
let table_info = TableInfo::load(yaml_data).unwrap();
assert_eq!(table_info.table_name, "my_simple_table");
assert_eq!(table_info.pk.name, "item_id");
assert_eq!(table_info.pk.attr_type, AttrType::S);
assert!(table_info.sk.is_none());Trait Implementations§
Source§impl<'de> Deserialize<'de> for TableInfo
impl<'de> Deserialize<'de> for TableInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for TableInfo
impl RefUnwindSafe for TableInfo
impl Send for TableInfo
impl Sync for TableInfo
impl Unpin for TableInfo
impl UnsafeUnpin for TableInfo
impl UnwindSafe for TableInfo
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> 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>
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