vortex_array/vtable/
mod.rsuse std::any::Any;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::ops::Deref;
use std::sync::Arc;
mod canonical;
mod compute;
mod metadata;
mod statistics;
mod validate;
mod validity;
mod variants;
mod visitor;
pub use canonical::*;
pub use compute::*;
pub use metadata::*;
pub use statistics::*;
pub use validate::*;
pub use validity::*;
pub use variants::*;
pub use visitor::*;
use crate::encoding::EncodingId;
use crate::Array;
#[derive(Debug, Clone)]
pub struct VTableRef(Inner);
#[derive(Debug, Clone)]
enum Inner {
Static(&'static dyn EncodingVTable),
Arc(Arc<dyn EncodingVTable>),
}
impl VTableRef {
pub const fn from_static(vtable: &'static dyn EncodingVTable) -> Self {
VTableRef(Inner::Static(vtable))
}
pub fn from_arc(vtable: Arc<dyn EncodingVTable>) -> Self {
VTableRef(Inner::Arc(vtable))
}
}
impl Deref for VTableRef {
type Target = dyn EncodingVTable;
fn deref(&self) -> &Self::Target {
match &self.0 {
Inner::Static(vtable) => *vtable,
Inner::Arc(vtable) => vtable.deref(),
}
}
}
pub trait EncodingVTable:
'static
+ Sync
+ Send
+ Debug
+ CanonicalVTable<Array>
+ ComputeVTable
+ MetadataVTable<Array>
+ StatisticsVTable<Array>
+ ValidateVTable<Array>
+ ValidityVTable<Array>
+ VariantsVTable<Array>
+ VisitorVTable<Array>
{
fn id(&self) -> EncodingId;
fn as_any(&self) -> &dyn Any;
}
impl PartialEq for dyn EncodingVTable + '_ {
fn eq(&self, other: &Self) -> bool {
self.id() == other.id()
}
}
impl Eq for dyn EncodingVTable + '_ {}
impl Hash for dyn EncodingVTable + '_ {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id().hash(state)
}
}