1use std::any::Any;
4use std::hash::Hash;
5use std::sync::Arc;
6
7pub use codegen::Block;
8
9use crate::arcstr::ArcStr;
10use crate::types::Io;
11
12#[cfg(test)]
13mod tests;
14
15#[doc = snippets::include_snippet!("substrate", "inverter")]
20pub trait Block: Hash + Eq + Send + Sync + Any {
21 type Io: Io;
23
24 fn name(&self) -> ArcStr {
30 arcstr::literal!("unnamed")
31 }
32
33 fn io(&self) -> Self::Io;
35}
36
37impl<T: Block> Block for Arc<T> {
38 type Io = T::Io;
39
40 fn name(&self) -> ArcStr {
41 T::name(self)
42 }
43
44 fn io(&self) -> Self::Io {
45 T::io(self)
46 }
47}