opcua_types/service_types/
argument.rs1#![allow(unused_attributes)]
9use std::io::{Read, Write};
10#[allow(unused_imports)]
11use crate::{
12 encoding::*,
13 basic_types::*,
14 service_types::impls::MessageInfo,
15 node_ids::ObjectId,
16 string::UAString,
17 node_id::NodeId,
18 localized_text::LocalizedText,
19};
20
21#[derive(Debug, Clone, PartialEq)]
22pub struct Argument {
23 pub name: UAString,
24 pub data_type: NodeId,
25 pub value_rank: i32,
26 pub array_dimensions: Option<Vec<u32>>,
27 pub description: LocalizedText,
28}
29
30impl MessageInfo for Argument {
31 fn object_id(&self) -> ObjectId {
32 ObjectId::Argument_Encoding_DefaultBinary
33 }
34}
35
36impl BinaryEncoder<Argument> for Argument {
37 fn byte_len(&self) -> usize {
38 let mut size = 0;
39 size += self.name.byte_len();
40 size += self.data_type.byte_len();
41 size += self.value_rank.byte_len();
42 size += byte_len_array(&self.array_dimensions);
43 size += self.description.byte_len();
44 size
45 }
46
47 #[allow(unused_variables)]
48 fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
49 let mut size = 0;
50 size += self.name.encode(stream)?;
51 size += self.data_type.encode(stream)?;
52 size += self.value_rank.encode(stream)?;
53 size += write_array(stream, &self.array_dimensions)?;
54 size += self.description.encode(stream)?;
55 Ok(size)
56 }
57
58 #[allow(unused_variables)]
59 fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
60 let name = UAString::decode(stream, decoding_options)?;
61 let data_type = NodeId::decode(stream, decoding_options)?;
62 let value_rank = i32::decode(stream, decoding_options)?;
63 let array_dimensions: Option<Vec<u32>> = read_array(stream, decoding_options)?;
64 let description = LocalizedText::decode(stream, decoding_options)?;
65 Ok(Argument {
66 name,
67 data_type,
68 value_rank,
69 array_dimensions,
70 description,
71 })
72 }
73}