zenoh_flow/model/record/
node.rs

1//
2// Copyright (c) 2021 - 2023 ZettaScale Technology
3//
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7// which is available at https://www.apache.org/licenses/LICENSE-2.0.
8//
9// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10//
11// Contributors:
12//   ZettaScale Zenoh Team, <zenoh@zettascale.tech>
13//
14
15use crate::model::record::PortRecord;
16use crate::types::{Configuration, NodeId, RuntimeId};
17use serde::{Deserialize, Serialize};
18
19/// A `SinkRecord` is an instance of a [`SinkDescriptor`](`crate::model::descriptor::SinkDescriptor`)
20#[derive(Serialize, Deserialize, Debug, Clone)]
21pub struct SinkRecord {
22    pub id: NodeId,
23    pub uid: u32,
24    pub inputs: Vec<PortRecord>,
25    pub uri: Option<String>,
26    pub configuration: Option<Configuration>,
27    pub runtime: RuntimeId,
28}
29
30impl std::fmt::Display for SinkRecord {
31    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
32        write!(f, "{} - Kind: Sink", self.id)
33    }
34}
35
36/// A `SourceRecord` is an instance of a [`SourceDescriptor`](`crate::model::descriptor::SourceDescriptor`)
37#[derive(Serialize, Deserialize, Debug, Clone)]
38pub struct SourceRecord {
39    pub id: NodeId,
40    pub uid: u32,
41    pub outputs: Vec<PortRecord>,
42    pub uri: Option<String>,
43    pub configuration: Option<Configuration>,
44    pub runtime: RuntimeId,
45}
46
47impl std::fmt::Display for SourceRecord {
48    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
49        write!(f, "{} - Kind: Source", self.id)
50    }
51}
52
53/// An `OperatorRecord` is an instance of an [`OperatorDescriptor`](`crate::model::descriptor::OperatorDescriptor`)
54#[derive(Serialize, Deserialize, Debug, Clone)]
55pub struct OperatorRecord {
56    pub id: NodeId,
57    pub uid: u32,
58    pub inputs: Vec<PortRecord>,
59    pub outputs: Vec<PortRecord>,
60    pub uri: Option<String>,
61    pub configuration: Option<Configuration>,
62    pub runtime: RuntimeId,
63}
64
65impl std::fmt::Display for OperatorRecord {
66    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
67        write!(f, "{} - Kind: Operator", self.id)
68    }
69}