Skip to main content

dataplane_sdk/core/model/
data_address.rs

1//  Copyright (c) 2026 Metaform Systems, Inc
2//
3//  This program and the accompanying materials are made available under the
4//  terms of the Apache License, Version 2.0 which is available at
5//  https://www.apache.org/licenses/LICENSE-2.0
6//
7//    SPDX-License-Identifier: Apache-2.0
8//
9//    Contributors:
10//         Metaform Systems, Inc. - initial API and implementation
11//
12
13use bon::Builder;
14use serde::{Deserialize, Serialize};
15
16#[derive(Debug, Serialize, Deserialize, Clone, Builder, PartialEq)]
17#[serde(rename_all = "camelCase")]
18#[builder(on(String, into))]
19pub struct DataAddress {
20    #[builder(default = "DataAddress".to_string())]
21    #[serde(default = "data_address")]
22    #[serde(rename = "@type")]
23    pub kind: String,
24    pub endpoint: String,
25    pub endpoint_type: String,
26    #[builder(default)]
27    #[serde(default)]
28    pub endpoint_properties: Vec<EndpointProperty>,
29}
30
31impl DataAddress {
32    pub fn get_property(&self, name: &str) -> Option<&str> {
33        self.endpoint_properties
34            .iter()
35            .find(|p| p.name == name)
36            .map(|p| p.value.as_str())
37    }
38}
39
40#[derive(Debug, Serialize, Deserialize, Clone, Builder, PartialEq)]
41#[serde(rename_all = "camelCase")]
42#[builder(on(String, into))]
43pub struct EndpointProperty {
44    #[builder(default = "EndpointProperty".to_string())]
45    #[serde(default = "endpoint_property")]
46    #[serde(rename = "@type")]
47    pub kind: String,
48    pub name: String,
49    pub value: String,
50}
51
52fn data_address() -> String {
53    "DataAddress".to_string()
54}
55
56fn endpoint_property() -> String {
57    "EndpointProperty".to_string()
58}