use nodo::prelude::*;
pub struct RawCloner<T>(T);
impl<T> RawCloner<T> {
pub fn new(blueprint: T) -> Self {
Self(blueprint)
}
}
impl<T: Clone + Send + Sync> Codelet for RawCloner<T> {
type Status = DefaultStatus;
type Config = ();
type Rx = ();
type Tx = DoubleBufferTx<T>;
type Signals = ();
fn build_bundles(_: &Self::Config) -> (Self::Rx, Self::Tx) {
((), DoubleBufferTx::new(1))
}
fn step(&mut self, _cx: Context<Self>, _: &mut Self::Rx, tx: &mut Self::Tx) -> Outcome {
tx.push(self.0.clone())?;
SUCCESS
}
}
pub struct Cloner<T>(T);
impl<T> Cloner<T> {
pub fn new(blueprint: T) -> Self {
Self(blueprint)
}
}
impl<T: Clone + Send + Sync> Codelet for Cloner<T> {
type Status = DefaultStatus;
type Config = ();
type Rx = ();
type Tx = MessageTx<T>;
type Signals = ();
fn build_bundles(_: &Self::Config) -> (Self::Rx, Self::Tx) {
((), MessageTx::new(1))
}
fn step(&mut self, cx: Context<Self>, _: &mut Self::Rx, tx: &mut Self::Tx) -> Outcome {
tx.push(cx.clocks.sys_mono.now(), self.0.clone())?;
SUCCESS
}
}