1use opcua::types::{NodeClass, NodeId};
2
3#[derive(Debug, Clone)]
4pub struct TreeChild {
5 pub node_id: NodeId,
6 pub browse_name: String,
7 pub display_name: String,
8 pub node_class: NodeClass,
9 pub has_children: bool,
10}
11
12#[derive(Debug, Clone)]
13pub struct NodeSummary {
14 pub node_id: NodeId,
15 pub attributes: Vec<NodeAttribute>,
16}
17
18#[derive(Debug, Clone)]
19pub struct NodeAttribute {
20 pub name: String,
21 pub value: ValueTree,
22}
23
24#[derive(Debug, Clone)]
25pub enum ValueTree {
26 Null,
27 Leaf(String),
28 Array(Vec<ValueTree>),
29 Object(Vec<(String, ValueTree)>),
30}
31
32impl ValueTree {
33 pub fn format_inline(&self) -> String {
35 use std::fmt::Write as _;
36 fn write(v: &ValueTree, out: &mut String) {
37 match v {
38 ValueTree::Null => out.push_str("<null>"),
39 ValueTree::Leaf(s) => out.push_str(s),
40 ValueTree::Array(items) => {
41 out.push('[');
42 for (i, item) in items.iter().enumerate() {
43 if i > 0 {
44 out.push_str(", ");
45 }
46 write(item, out);
47 }
48 out.push(']');
49 }
50 ValueTree::Object(fields) => {
51 out.push('{');
52 for (i, (k, val)) in fields.iter().enumerate() {
53 if i > 0 {
54 out.push_str(", ");
55 }
56 let _ = write!(out, "{k}: ");
57 write(val, out);
58 }
59 out.push('}');
60 }
61 }
62 }
63 let mut out = String::new();
64 write(self, &mut out);
65 out
66 }
67}
68
69#[derive(Debug, Clone)]
70pub struct AuthSpec {
71 pub mode: AuthMode,
72 pub username: String,
73 pub password: String,
74 pub cert_path: String,
75 pub key_path: String,
76}
77
78#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
79pub enum AuthMode {
80 #[default]
81 Anonymous,
82 UserName,
83 Certificate,
84}
85
86#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
87pub enum SecurityMode {
88 #[default]
89 None,
90 Sign,
91 SignAndEncrypt,
92}
93
94impl SecurityMode {
95 pub fn label(self) -> &'static str {
96 match self {
97 SecurityMode::None => "None",
98 SecurityMode::Sign => "Sign",
99 SecurityMode::SignAndEncrypt => "SignAndEncrypt",
100 }
101 }
102}
103
104#[derive(Debug, Clone)]
105pub struct EndpointInfo {
106 pub endpoint_url: String,
107 pub security_policy: String,
108 pub security_policy_uri: String,
109 pub security_mode: SecurityMode,
110 pub security_level: u8,
111 pub supports_anonymous: bool,
112 pub supports_username: bool,
113 pub supports_certificate: bool,
114}
115
116#[derive(Debug, Clone)]
117pub struct MethodArgument {
118 pub name: String,
119 pub description: String,
120 pub data_type: NodeId,
121 pub value_rank: i32,
122 pub type_label: String,
123}
124
125#[derive(Debug, Clone)]
126pub struct MethodSignature {
127 pub parent_object: NodeId,
128 pub method_node: NodeId,
129 pub method_display_name: String,
130 pub inputs: Vec<MethodArgument>,
131 pub outputs: Vec<MethodArgument>,
132}
133
134#[derive(Debug, Clone)]
135pub struct MethodCallOutcome {
136 pub status: String,
137 pub outputs: Vec<ValueTree>,
138 pub input_arg_errors: Vec<Option<String>>,
139}
140
141#[derive(Debug, Clone)]
142pub struct ReferenceRow {
143 pub reference_type: String,
144 pub is_forward: bool,
145 pub target_node_id: NodeId,
146 pub target_browse_name: String,
147 pub target_display_name: String,
148 pub target_node_class: NodeClass,
149}
150
151#[derive(Debug, Clone, Copy, PartialEq, Eq)]
152pub enum LogLevel {
153 Error,
154 Warn,
155 Info,
156 Debug,
157 Trace,
158}
159
160#[derive(Debug, Clone)]
161pub struct LogLine {
162 pub level: LogLevel,
163 pub target: String,
164 pub message: String,
165}