hydro2_operator/
operator.rs1crate::ix!();
3
4pub type NetworkNodeIoChannelArray<NetworkItem> = [Option<Arc<AsyncRwLock<NetworkItem>>>; 4];
5pub type NetworkNodeIoChannelValues<NetworkItem> = [Option<NetworkItem>; 4];
6pub type NetworkNodeIoChannelReadGuardArray<'a,NetworkItem> = [Option<AsyncRwLockReadGuard<'a,NetworkItem>>; 4];
7pub type NetworkNodeIoChannelWriteGuardArray<'a,NetworkItem> = [Option<AsyncRwLockWriteGuard<'a,NetworkItem>>; 4];
8
9#[async_trait]
13pub trait Operator<NetworkItem>: Debug + Named + Send + Sync
14where NetworkItem: Debug + Send + Sync
15{
16 fn opcode(&self) -> std::sync::Arc<dyn OpCode>;
19
20 fn input_count(&self) -> usize;
22
23 fn output_count(&self) -> usize;
25
26 fn input_port_type_str(&self, port: usize) -> Option<&'static str>;
29
30 fn output_port_type_str(&self, port: usize) -> Option<&'static str>;
33
34 fn input_port_connection_required(&self, port: usize) -> bool;
36
37 fn output_port_connection_required(&self, port: usize) -> bool;
39
40 async fn execute(
43 &self,
44 input: [Option<&NetworkItem>; 4],
45 output: &mut [Option<NetworkItem>; 4],
46 ) -> NetResult<()>;
47}
48
49pub trait IntoArcOperator<NetworkItem> {
51 fn into_arc_operator(self) -> Arc<dyn Operator<NetworkItem>>;
52}
53
54impl<T,NetworkItem> IntoArcOperator<NetworkItem> for T
55where
56 T: Operator<NetworkItem> + 'static,
57 NetworkItem: Debug + Send + Sync,
58{
59 fn into_arc_operator(self) -> Arc<dyn Operator<NetworkItem>> {
60 Arc::new(self)
61 }
62}
63
64pub trait OperatorSignature {
68 type Input0;
69 type Input1;
70 type Input2;
71 type Input3;
72 type Output0;
73 type Output1;
74 type Output2;
75 type Output3;
76}