Progress on syncblock macro

This commit is contained in:
2026-03-19 21:53:07 +01:00
parent 2baee8d28b
commit 6e2283755a
5 changed files with 527 additions and 58 deletions

View File

@ -1,7 +1,6 @@
use crate::{
edge::BlockIOIndex,
io::{AnonymousStreamConsumer, AnonymousStreamProducer},
};
use crate::edge::BlockIOIndex;
use crate::io::AnonymousStreamConsumer;
use crate::io::AnonymousStreamProducer;
pub enum BlockResult
{
@ -51,14 +50,14 @@ pub trait Block
// Represents the input, output, state types
// that a SyncBlock will have to interacti with
pub trait SyncBlockIO
pub trait SyncBlockIO<'view>
{
type StateView;
type Input;
type Output;
}
pub trait SyncBlock: SyncBlockIO
pub trait SyncBlock<'view>: SyncBlockIO<'view>
{
fn sync_work(state: Self::StateView, input: Self::Input) -> Option<Self::Output>;
}

View File

@ -1,9 +1,9 @@
use std::{
any::Any,
collections::HashMap,
ops::{Deref, DerefMut},
sync::{Arc, Mutex},
};
use std::any::Any;
use std::collections::HashMap;
use std::ops::Deref;
use std::ops::DerefMut;
use std::sync::Arc;
use std::sync::Mutex;
// Tags a particular sample within a specific stream
#[derive(Clone)]
@ -20,6 +20,19 @@ pub struct Tag
pub data: Arc<Mutex<HashMap<String, Arc<dyn Any + Send + Sync>>>>,
}
impl Tag
{
pub fn merge_tag_opts<const N: usize>(tag_opts: [Option<Tag>; N]) -> Option<Tag>
{
let mut out_tag = None;
for tag in tag_opts.iter()
{
out_tag = out_tag.merge(tag);
}
out_tag
}
}
pub trait TagValue: Clone {}
impl<T> TagValue for T where T: Clone {}