wick_config/config/
components.rs

1mod grpcurl;
2mod http_client;
3mod manifest;
4mod native;
5mod reference;
6mod sql;
7mod types;
8mod wasm;
9
10use std::borrow::Cow;
11
12pub use grpcurl::*;
13pub use http_client::*;
14pub use manifest::*;
15pub use native::*;
16pub use reference::*;
17pub use sql::*;
18pub use types::*;
19pub use wasm::*;
20use wick_interface_types::{Field, OperationSignatures};
21
22pub trait OperationConfig {
23  /// The name of the operation.
24  fn name(&self) -> &str;
25
26  /// The inputs to the operation.
27  fn inputs(&self) -> Cow<Vec<Field>>;
28
29  /// The outpus to the operation.
30  fn outputs(&self) -> Cow<Vec<Field>>;
31}
32
33pub trait ComponentConfig: OperationSignatures {
34  type Operation: OperationConfig;
35
36  /// Get the operations defined by this configuration.
37  fn operations(&self) -> &[Self::Operation];
38
39  /// Get the operations defined by this configuration.
40  fn operations_mut(&mut self) -> &mut Vec<Self::Operation>;
41
42  /// Get an operation definition by name.
43  fn get_operation(&self, name: &str) -> Option<&Self::Operation> {
44    self.operations().iter().find(|o| o.name() == name)
45  }
46}