protoflow-derive-0.0.4 has been yanked.
Protoflow

🚧 This is presently under heavy construction.
🛠️ Prerequisites
⬇️ Installation
Installation via Cargo
$ cargo add protoflow
👉 Examples
Importing the library
use protoflow::*;
Authoring a simple DROP block
use protoflow::{Block, BlockError, InputPort, Message, PortDescriptor, Scheduler};
pub struct Drop<T: Message>(InputPort<T>);
impl<T: Message> Block for Drop<T> {
fn inputs(&self) -> Vec<PortDescriptor> {
vec![PortDescriptor::from(&self.0)]
}
fn outputs(&self) -> Vec<PortDescriptor> {
vec![] }
fn execute(&mut self, _scheduler: &dyn Scheduler) -> Result<(), BlockError> {
while let Some(message) = self.0.receive()? {
drop(message);
}
Ok(())
}
}
Authoring a simple DELAY block
use protoflow::{Block, BlockError, InputPort, Message, OutputPort, Port, PortDescriptor, Scheduler};
use std::time::Duration;
pub struct Delay<T: Message> {
input: InputPort<T>,
output: OutputPort<T>,
delay: Duration,
}
impl<T: Message> Block for Delay<T> {
fn inputs(&self) -> Vec<PortDescriptor> {
vec![PortDescriptor::from(&self.input)]
}
fn outputs(&self) -> Vec<PortDescriptor> {
vec![PortDescriptor::from(&self.output)]
}
fn execute(&mut self, scheduler: &dyn Scheduler) -> Result<(), BlockError> {
while let Some(message) = self.input.receive()? {
scheduler.sleep_for(self.delay)?;
if self.output.is_connected() {
self.output.send(&message)?;
}
}
Ok(())
}
}
📚 Reference
Features
Runtimes
Transports
Blocks
TODO
👨💻 Development
$ git clone https://github.com/artob/protoflow.git
