#![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "alloc")] extern crate alloc; #[cfg_attr(feature = "log", macro_use)] #[cfg(feature = "log")] extern crate log; pub use crate as graphene_core; pub mod consts; pub mod generic; pub mod logic; pub mod ops; pub mod structural; #[cfg(feature = "std")] pub mod text; #[cfg(feature = "std")] pub mod uuid; pub mod value; #[cfg(feature = "gpu")] pub mod gpu; #[cfg(feature = "alloc")] pub mod memo; pub mod storage; pub mod raster; #[cfg(feature = "alloc")] pub mod transform; #[cfg(feature = "alloc")] mod graphic_element; #[cfg(feature = "alloc")] pub use graphic_element::*; #[cfg(feature = "alloc")] pub mod vector; #[cfg(feature = "alloc")] pub mod application_io; pub mod quantization; use core::any::TypeId; pub use memo::MemoHash; pub use raster::Color; pub use types::Cow; // pub trait Node: for<'n> NodeIO<'n> { /// The node trait allows for defining any node. Nodes can only take one input, however they can store references to other nodes inside the struct. /// See `node-graph/README.md` for information on how to define a new node. pub trait Node<'i, Input: 'i>: 'i { type Output: 'i; /// Evaluates the node with the single specified input. fn eval(&'i self, input: Input) -> Self::Output; /// Resets the node, e.g. the LetNode's cache is set to None. fn reset(&self) {} /// Returns the name of the node for diagnostic purposes. fn node_name(&self) -> &'static str { core::any::type_name::() } /// Serialize the node which is used for the `introspect` function which can retrieve values from monitor nodes. #[cfg(feature = "std")] fn serialize(&self) -> Option> { log::warn!("Node::serialize not implemented for {}", core::any::type_name::()); None } } pub trait NodeMut<'i, Input: 'i>: 'i { type MutOutput: 'i; fn eval_mut(&'i mut self, input: Input) -> Self::MutOutput; } pub trait NodeOnce<'i, Input> where Input: 'i, { type OnceOutput: 'i; fn eval_once(self, input: Input) -> Self::OnceOutput; } impl<'i, T: Node<'i, I>, I: 'i> NodeOnce<'i, I> for &'i T { type OnceOutput = T::Output; fn eval_once(self, input: I) -> Self::OnceOutput { (self).eval(input) } } impl<'i, T: Node<'i, I> + ?Sized, I: 'i> NodeMut<'i, I> for &'i T { type MutOutput = T::Output; fn eval_mut(&'i mut self, input: I) -> Self::MutOutput { (*self).eval(input) } } #[cfg(feature = "alloc")] mod types; #[cfg(feature = "alloc")] pub use types::*; pub trait NodeIO<'i, Input: 'i>: 'i + Node<'i, Input> where Self::Output: 'i + StaticTypeSized, Input: 'i + StaticTypeSized, { fn input_type(&self) -> TypeId { TypeId::of::() } fn input_type_name(&self) -> &'static str { core::any::type_name::() } fn output_type(&self) -> core::any::TypeId { TypeId::of::<::Static>() } fn output_type_name(&self) -> &'static str { core::any::type_name::() } #[cfg(feature = "alloc")] fn to_node_io(&self, parameters: Vec) -> NodeIOTypes { NodeIOTypes { input: concrete!(::Static), output: concrete!(::Static), parameters, } } } impl<'i, N: Node<'i, I>, I> NodeIO<'i, I> for N where N::Output: 'i + StaticTypeSized, I: 'i + StaticTypeSized, { } impl<'i, 's: 'i, I: 'i, N: Node<'i, I> + ?Sized> Node<'i, I> for &'i N { type Output = N::Output; fn eval(&'i self, input: I) -> N::Output { (*self).eval(input) } } #[cfg(feature = "alloc")] impl<'i, 's: 'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for Box { type Output = O; fn eval(&'i self, input: I) -> O { (**self).eval(input) } } #[cfg(feature = "alloc")] impl<'i, 's: 'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for alloc::sync::Arc { type Output = O; fn eval(&'i self, input: I) -> O { (**self).eval(input) } } use dyn_any::StaticTypeSized; use core::pin::Pin; #[cfg(feature = "alloc")] impl<'i, I: 'i, O: 'i> Node<'i, I> for Pin + 'i>> { type Output = O; fn eval(&'i self, input: I) -> O { (**self).eval(input) } } impl<'i, I: 'i, O: 'i> Node<'i, I> for Pin<&'i (dyn NodeIO<'i, I, Output = O> + 'i)> { type Output = O; fn eval(&'i self, input: I) -> O { (**self).eval(input) } } #[cfg(feature = "alloc")] pub use crate::application_io::{SurfaceFrame, SurfaceId}; #[cfg(feature = "wasm")] pub type WasmSurfaceHandle = application_io::SurfaceHandle; #[cfg(feature = "wasm")] pub type WasmSurfaceHandleFrame = application_io::SurfaceHandleFrame; pub use dyn_any::{WasmNotSend, WasmNotSync};