pub mod sid;
pub use sid::*;
pub mod spath;
pub use spath::*;
pub mod graph;
pub use graph::*;
pub mod sref;
pub use sref::*;
pub mod node;
pub use node::*;
pub mod data;
pub use data::*;
pub mod components;
pub use components::*;
pub mod formats;
pub use formats::*;
pub mod libraries;
pub use libraries::*;
use std::any::Any;
use serde::{Deserialize, Serialize};
#[typetag::serde]
pub trait StofData: AsDynAny + std::fmt::Debug + DataClone + Send + Sync {
fn core_data(&self) -> bool {
false
}
fn is_container(&self) -> bool {
false
}
#[allow(unused)]
fn hard_node_ref(&self, node: &NodeRef) -> bool {
false
}
#[allow(unused)]
fn deep_copy(&self, graph: &mut Graph, context: Option<NodeRef>) -> Box::<dyn StofData> {
self.clone_data()
}
}
pub trait AsDynAny {
fn as_dyn_any(&self) -> &dyn Any;
fn as_mut_dyn_any(&mut self) -> &mut dyn Any;
}
impl<T: StofData + Any> AsDynAny for T {
fn as_dyn_any(&self) -> &dyn Any {
self
}
fn as_mut_dyn_any(&mut self) -> &mut dyn Any {
self
}
}
pub trait DataClone {
fn clone_data(&self) -> Box<dyn StofData>;
}
impl<T: StofData + Clone + 'static> DataClone for T {
fn clone_data(&self) -> Box<dyn StofData> {
Box::new(self.clone())
}
}
impl Clone for Box<dyn StofData> {
fn clone(&self) -> Box<dyn StofData> {
self.clone_data()
}
}
#[typetag::serde(name = "String")]
impl StofData for String {
fn core_data(&self) -> bool {
return true;
}
}
#[typetag::serde(name = "None")]
impl StofData for () {
fn core_data(&self) -> bool {
return true;
}
}
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct StofDataContainer {
pub contained: Vec<u8>,
}
#[typetag::serde(name = "Contained")]
impl StofData for StofDataContainer {
fn core_data(&self) -> bool {
return true;
}
fn is_container(&self) -> bool {
return true;
}
}