use crate::{data::Data, table::grid::Column};
use std::{
any::{Any, TypeId},
fmt::Debug,
};
mod seal {
pub trait Seal {}
}
pub trait Cell: Send + Sync + 'static + Debug + seal::Seal {
fn cell_type_id(&self) -> TypeId;
fn into_any_box(self: Box<Self>) -> Box<dyn Any>;
fn into_cell(self) -> Box<dyn Cell>;
fn into_column(self: Box<Self>) -> Box<dyn Column>;
}
impl<T: Cell> seal::Seal for T {}
impl<T: Data> Cell for T {
fn cell_type_id(&self) -> TypeId { T::ID }
fn into_any_box(self: Box<Self>) -> Box<dyn Any> { self }
fn into_cell(self) -> Box<dyn Cell> { Box::new(self) }
fn into_column(self: Box<Self>) -> Box<dyn Column> { vec![*self].into() }
}