use std::marker::PhantomData;
use crate::{convert::IntoAttributeValue, Attributes, Table};
pub struct Key {
pub(crate) table_name: String,
pub(crate) key: Attributes,
}
impl Key {
pub fn new<T: Table, K: IntoAttributeValue>(key_name: &str, key_value: K) -> Self {
Self {
table_name: T::table_name(),
key: <_>::into_iter([(key_name.to_owned(), key_value.into_av())]).collect(),
}
}
pub fn insert(&mut self, key_name: impl Into<String>, key_value: impl IntoAttributeValue) {
self.key.insert(key_name.into(), key_value.into_av());
}
}
pub trait Builder<'d, D: 'd + ?Sized, R: From<Key>>: Table {
type Builder;
fn key(client: &'d D) -> Self::Builder;
}
pub struct Expr<'d, D: 'd + ?Sized, Input, Table> {
pub(crate) client: &'d D,
pub(crate) input: Input,
pub(crate) _phantom: PhantomData<Table>,
}
impl<'d, D: 'd + ?Sized, Input, Table> Expr<'d, D, Input, Table>
where
Input: From<Key>,
{
pub fn new(client: &'d D, key: Key) -> Self {
let input = key.into();
Self { client, input, _phantom: PhantomData }
}
}