pub trait Block: Serialize + DeserializeOwned + Hash + Eq + Send + Sync + Any {
type Io: Io;
// Required methods
fn id() -> ArcStr;
fn io(&self) -> Self::Io;
// Provided method
fn name(&self) -> ArcStr { ... }
}
Expand description
A block that can be instantiated by Substrate.
§Examples
#[derive(Io, Clone, Default, Debug)]
pub struct InverterIo {
pub vdd: InOut<Signal>,
pub vss: InOut<Signal>,
pub din: Input<Signal>,
pub dout: Output<Signal>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Hash, PartialEq, Eq)]
pub struct Inverter {
strength: usize,
}
impl Block for Inverter {
type Io = InverterIo;
fn id() -> arcstr::ArcStr {
arcstr::literal!("inverter")
}
fn name(&self) -> arcstr::ArcStr {
arcstr::format!("inverter_{}", self.strength)
}
fn io(&self) -> Self::Io {
Default::default()
}
}
Required Associated Types§
Required Methods§
Provided Methods§
Object Safety§
This trait is not object safe.