wick_config/config/component_config/
wasmrs.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 WasmRsComponent {
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  /// The default buffer size to use for the component.
39  #[asset(skip)]
40  #[builder(default)]
41  #[serde(skip_serializing_if = "Option::is_none")]
42  pub(crate) max_packet_size: Option<u32>,
43}
44
45impl OperationSignatures for WasmRsComponent {
46  fn operation_signatures(&self) -> Vec<wick_interface_types::OperationSignature> {
47    self.operations.clone().map_into()
48  }
49}
50
51impl ComponentConfig for WasmRsComponent {
52  type Operation = OperationDefinition;
53
54  fn operations(&self) -> &[Self::Operation] {
55    &self.operations
56  }
57
58  fn operations_mut(&mut self) -> &mut Vec<Self::Operation> {
59    &mut self.operations
60  }
61}