opcua_types/service_types/
annotation.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 date_time::DateTime,
18};
19
20#[derive(Debug, Clone, PartialEq)]
21pub struct Annotation {
22 pub message: UAString,
23 pub user_name: UAString,
24 pub annotation_time: DateTime,
25}
26
27impl MessageInfo for Annotation {
28 fn object_id(&self) -> ObjectId {
29 ObjectId::Annotation_Encoding_DefaultBinary
30 }
31}
32
33impl BinaryEncoder<Annotation> for Annotation {
34 fn byte_len(&self) -> usize {
35 let mut size = 0;
36 size += self.message.byte_len();
37 size += self.user_name.byte_len();
38 size += self.annotation_time.byte_len();
39 size
40 }
41
42 #[allow(unused_variables)]
43 fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
44 let mut size = 0;
45 size += self.message.encode(stream)?;
46 size += self.user_name.encode(stream)?;
47 size += self.annotation_time.encode(stream)?;
48 Ok(size)
49 }
50
51 #[allow(unused_variables)]
52 fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
53 let message = UAString::decode(stream, decoding_options)?;
54 let user_name = UAString::decode(stream, decoding_options)?;
55 let annotation_time = DateTime::decode(stream, decoding_options)?;
56 Ok(Annotation {
57 message,
58 user_name,
59 annotation_time,
60 })
61 }
62}