wick_component/adapters/generic/
raw.rs

1#[macro_export]
2/// This macro will generate the implementations for operations, passing through packets without processing.
3macro_rules! generic_raw {
4  ($name:ident => $handler:ident) => {
5    #[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
6    #[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
7    impl $name::Operation for Component {
8      type Error = wick_component::AnyError;
9      type Inputs = $name::Inputs;
10      type Outputs = $name::Outputs;
11      type Config = $name::Config;
12
13      async fn $name(
14        inputs: Self::Inputs,
15        outputs: Self::Outputs,
16        ctx: Context<Self::Config>,
17      ) -> Result<(), Self::Error> {
18        $handler(inputs, outputs, ctx).await
19      }
20    }
21  };
22}
23
24// /// Operation helper for common unary operations that have one input and control their own output.
25// pub async fn raw<'out, 'c, INPUT, OUTPUTS, CONTEXT, F, E>(
26//   input: WickStream<Packet>,
27//   outputs: OUTPUTS,
28//   ctx: &'c CONTEXT,
29//   func: &'static F,
30// ) -> Result<(), E>
31// where
32//   CONTEXT: Clone + wasmrs_runtime::ConditionallySendSync,
33//   INPUT: serde::de::DeserializeOwned + Clone + wasmrs_runtime::ConditionallySendSync,
34//   OUTPUTS: WasmRsChannel + Broadcast + wasmrs_runtime::ConditionallySendSync,
35//   F: Fn(INPUT, OUTPUTS, CONTEXT) -> BoxFuture<Result<(), E>> + wasmrs_runtime::ConditionallySendSync,
36//   E: std::fmt::Display + wasmrs_runtime::ConditionallySendSync,
37// {
38//   let _ = inner::<INPUT, OUTPUTS, CONTEXT, F, E>(input, outputs, ctx, func).await;
39
40//   Ok(())
41// }