wick_config/config/common/
operation_definition.rs

1#![allow(missing_docs)] // delete when we move away from the `property` crate.
2
3use std::borrow::Cow;
4
5use wick_interface_types::Field;
6
7use crate::config::components::OperationConfig;
8
9#[derive(Debug, derive_builder::Builder, Clone, property::Property, serde::Serialize)]
10#[property(get(disable), set(private), mut(disable))]
11#[builder(setter(into))]
12/// The generic definition of an Operation without any implementation details.
13pub struct OperationDefinition {
14  /// The name of the schematic.
15  pub(crate) name: String,
16
17  /// Any configuration required for the component to operate.
18  #[builder(default)]
19  #[serde(skip_serializing_if = "Vec::is_empty")]
20  pub(crate) config: Vec<Field>,
21
22  /// A list of the input types for the operation.
23  #[builder(default)]
24  #[serde(skip_serializing_if = "Vec::is_empty")]
25  pub(crate) inputs: Vec<Field>,
26
27  /// A list of the input types for the operation.
28  #[builder(default)]
29  #[serde(skip_serializing_if = "Vec::is_empty")]
30  pub(crate) outputs: Vec<Field>,
31}
32
33impl OperationConfig for OperationDefinition {
34  fn name(&self) -> &str {
35    &self.name
36  }
37
38  fn inputs(&self) -> Cow<Vec<Field>> {
39    Cow::Borrowed(&self.inputs)
40  }
41
42  fn outputs(&self) -> Cow<Vec<Field>> {
43    Cow::Borrowed(&self.outputs)
44  }
45}