wasmflow_boundary/
incoming.rs

1/// A map of port name to payload message.
2#[derive(Debug)]
3pub struct IncomingPayload<P, C>
4where
5  P: std::fmt::Debug,
6  C: std::fmt::Debug,
7{
8  id: u32,
9  payload: P,
10  config: Option<C>,
11}
12
13impl<P, C> IncomingPayload<P, C>
14where
15  P: std::fmt::Debug + serde::de::DeserializeOwned,
16  C: std::fmt::Debug + serde::de::DeserializeOwned,
17{
18  /// Instantiate a new IncomingPayload
19  pub fn new(id: u32, payload: P, config: Option<C>) -> Self {
20    Self { id, payload, config }
21  }
22
23  /// Get the transaction ID associated with this [IncomingPayload].
24  #[must_use]
25  pub fn id(&self) -> u32 {
26    self.id
27  }
28
29  /// Get the main payload.
30  #[must_use]
31  pub fn payload(&self) -> &P {
32    &self.payload
33  }
34
35  /// Get the configuration associated with the incoming payload.
36  #[must_use]
37  pub fn config(&self) -> &Option<C> {
38    &self.config
39  }
40
41  /// Get the state used for the next run of the job.
42  #[must_use]
43  pub fn into_parts(self) -> (P, Option<C>) {
44    (self.payload, self.config)
45  }
46}