use uuid::Uuid;
use crate::{im::ImDataSource, traits::ValueSet};
pub struct ImTable<E, V = serde_json::Value> {
pub(super) data_source: ImDataSource<V>,
pub(super) table_name: String,
_phantom: std::marker::PhantomData<E>,
}
impl<E, V> ImTable<E, V> {
pub fn new(data_source: &ImDataSource<V>, table_name: &str) -> Self
where
V: Clone,
{
Self {
data_source: data_source.clone(),
table_name: table_name.to_string(),
_phantom: std::marker::PhantomData,
}
}
pub fn generate_id(&self) -> String {
Uuid::new_v4().to_string()
}
}
impl<E, V> ValueSet for ImTable<E, V>
where
V: Clone + Send + Sync + 'static,
{
type Id = String;
type Value = V;
}