use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::{edge::meta::EdgeMeta, query::IndexMeta};
pub trait Edge: Serialize + for<'de> Deserialize<'de> + Sized + Send + Sync + 'static {
const TYPE: &'static str;
fn type_name(&self) -> &'static str {
Self::TYPE
}
fn meta(&self) -> &EdgeMeta;
fn meta_mut(&mut self) -> &mut EdgeMeta;
fn index_meta(&self) -> IndexMeta;
}
pub trait EdgeMetaTrait {
fn from(&self) -> Uuid;
fn to(&self) -> Uuid;
}
impl<E> EdgeMetaTrait for E
where
E: Edge,
{
fn from(&self) -> uuid::Uuid {
self.meta().from()
}
fn to(&self) -> uuid::Uuid {
self.meta().to()
}
}