Working base

This commit is contained in:
2026-03-13 21:57:10 +01:00
parent 092fb0191f
commit 866a5dd501
23 changed files with 1050 additions and 321 deletions

View File

@ -2,7 +2,12 @@ use crate::edge::{AnonymousStreamConsumer, AnonymousStreamProducer, BlockIOIndex
pub enum BlockResult
{
// Signifies that the block can be scheduled again.
Ok,
// Signifies that the block finished its work
// Running it again would be useless
// This triggers the graph shutdown
Terminated,
}
@ -28,6 +33,12 @@ pub trait BlockIO
output_index: usize,
capacity: usize,
) -> (AnonymousStreamProducer, AnonymousStreamConsumer);
// Meta information
fn get_block_name(&self) -> &'static str;
fn get_input_names(&self) -> Vec<&'static str>;
fn get_output_names(&self) -> Vec<&'static str>;
fn get_output_type_names(&self) -> Vec<&'static str>;
}
pub trait Block
@ -39,8 +50,11 @@ pub trait SyncBlock
{
type Input;
type Output;
type State;
fn sync_work(&mut self, input: Self::Input) -> Self::Output;
fn sync_work(state: &mut Self::State, input: Self::Input) -> Option<Self::Output>;
}
pub trait GraphableBlock: Block + BlockIO {}
impl<T> GraphableBlock for T where T: Block + BlockIO {}