wick_config/config/component_config/
wasm_component_model.rs

1use wick_interface_types::{Field, OperationSignatures};
2
3use crate::config::components::ComponentConfig;
4use crate::config::{self, ExposedVolume, OperationDefinition};
5use crate::utils::VecMapInto;
6
7#[derive(
8  Debug, Clone, derive_asset_container::AssetManager, derive_builder::Builder, property::Property, serde::Serialize,
9)]
10#[property(get(public), set(public), mut(public, suffix = "_mut"))]
11#[builder(setter(into))]
12#[asset(asset(config::AssetReference))]
13#[must_use]
14/// The internal representation of a Wick manifest.
15pub struct WasmComponentDefinition {
16  /// The location of the component.
17  pub(crate) reference: config::AssetReference,
18
19  /// The configuration for the component.
20  #[asset(skip)]
21  #[builder(default)]
22  #[serde(skip_serializing_if = "Vec::is_empty")]
23  pub(crate) config: Vec<Field>,
24
25  /// Volumes to expose to the component and the paths they map to.
26  #[asset(skip)]
27  #[builder(default)]
28  #[serde(skip_serializing_if = "Vec::is_empty")]
29  pub(crate) volumes: Vec<ExposedVolume>,
30
31  /// The operations defined by the component.
32  #[asset(skip)]
33  #[builder(default)]
34  #[property(skip)]
35  #[serde(skip_serializing_if = "Vec::is_empty")]
36  pub(crate) operations: Vec<OperationDefinition>,
37}
38
39impl OperationSignatures for WasmComponentDefinition {
40  fn operation_signatures(&self) -> Vec<wick_interface_types::OperationSignature> {
41    self.operations.clone().map_into()
42  }
43}
44
45impl ComponentConfig for WasmComponentDefinition {
46  type Operation = OperationDefinition;
47
48  fn operations(&self) -> &[Self::Operation] {
49    &self.operations
50  }
51
52  fn operations_mut(&mut self) -> &mut Vec<Self::Operation> {
53    &mut self.operations
54  }
55}