opcua_types/service_types/
enums.rs

1// OPCUA for Rust
2// SPDX-License-Identifier: MPL-2.0
3// Copyright (C) 2017-2022 Adam Lock
4//
5// This file was autogenerated from Opc.Ua.Types.bsd by tools/schema/gen_types.js
6//
7// DO NOT EDIT THIS FILE
8#![allow(unused_attributes)]
9#![allow(non_upper_case_globals)]
10use std::io::{Read, Write};
11use crate::encoding::*;
12use crate::status_codes::StatusCode;
13use bitflags;
14
15/// The possible encodings for a NodeId value.
16#[derive(Debug, Copy, Clone, PartialEq)]
17pub enum NodeIdType {
18    TwoByte = 0,
19    FourByte = 1,
20    Numeric = 2,
21    String = 3,
22    Guid = 4,
23    ByteString = 5,
24}
25
26impl BinaryEncoder<NodeIdType> for NodeIdType {
27    fn byte_len(&self) -> usize {
28        1
29    }
30
31    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
32        write_u8(stream, *self as u8)
33    }
34
35    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
36        let value = read_u8(stream)?;
37        match value {
38            0 => Ok(Self::TwoByte),
39            1 => Ok(Self::FourByte),
40            2 => Ok(Self::Numeric),
41            3 => Ok(Self::String),
42            4 => Ok(Self::Guid),
43            5 => Ok(Self::ByteString),
44            v => {
45                error!("Invalid value {} for enum NodeIdType", v);
46                Err(StatusCode::BadUnexpectedError)
47            }
48        }
49    }
50}
51
52#[derive(Debug, Copy, Clone, PartialEq)]
53pub enum NamingRuleType {
54    Mandatory = 1,
55    Optional = 2,
56    Constraint = 3,
57}
58
59impl BinaryEncoder<NamingRuleType> for NamingRuleType {
60    fn byte_len(&self) -> usize {
61        4
62    }
63
64    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
65        write_i32(stream, *self as i32)
66    }
67
68    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
69        let value = read_i32(stream)?;
70        match value {
71            1 => Ok(Self::Mandatory),
72            2 => Ok(Self::Optional),
73            3 => Ok(Self::Constraint),
74            v => {
75                error!("Invalid value {} for enum NamingRuleType", v);
76                Err(StatusCode::BadUnexpectedError)
77            }
78        }
79    }
80}
81
82#[derive(Debug, Copy, Clone, PartialEq)]
83pub enum OpenFileMode {
84    Read = 1,
85    Write = 2,
86    EraseExisting = 4,
87    Append = 8,
88}
89
90impl BinaryEncoder<OpenFileMode> for OpenFileMode {
91    fn byte_len(&self) -> usize {
92        4
93    }
94
95    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
96        write_i32(stream, *self as i32)
97    }
98
99    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
100        let value = read_i32(stream)?;
101        match value {
102            1 => Ok(Self::Read),
103            2 => Ok(Self::Write),
104            4 => Ok(Self::EraseExisting),
105            8 => Ok(Self::Append),
106            v => {
107                error!("Invalid value {} for enum OpenFileMode", v);
108                Err(StatusCode::BadUnexpectedError)
109            }
110        }
111    }
112}
113
114#[derive(Debug, Copy, Clone, PartialEq)]
115pub enum IdentityCriteriaType {
116    UserName = 1,
117    Thumbprint = 2,
118    Role = 3,
119    GroupId = 4,
120    Anonymous = 5,
121    AuthenticatedUser = 6,
122}
123
124impl BinaryEncoder<IdentityCriteriaType> for IdentityCriteriaType {
125    fn byte_len(&self) -> usize {
126        4
127    }
128
129    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
130        write_i32(stream, *self as i32)
131    }
132
133    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
134        let value = read_i32(stream)?;
135        match value {
136            1 => Ok(Self::UserName),
137            2 => Ok(Self::Thumbprint),
138            3 => Ok(Self::Role),
139            4 => Ok(Self::GroupId),
140            5 => Ok(Self::Anonymous),
141            6 => Ok(Self::AuthenticatedUser),
142            v => {
143                error!("Invalid value {} for enum IdentityCriteriaType", v);
144                Err(StatusCode::BadUnexpectedError)
145            }
146        }
147    }
148}
149
150#[derive(Debug, Copy, Clone, PartialEq)]
151pub enum TrustListMasks {
152    None = 0,
153    TrustedCertificates = 1,
154    TrustedCrls = 2,
155    IssuerCertificates = 4,
156    IssuerCrls = 8,
157    All = 15,
158}
159
160impl BinaryEncoder<TrustListMasks> for TrustListMasks {
161    fn byte_len(&self) -> usize {
162        4
163    }
164
165    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
166        write_i32(stream, *self as i32)
167    }
168
169    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
170        let value = read_i32(stream)?;
171        match value {
172            0 => Ok(Self::None),
173            1 => Ok(Self::TrustedCertificates),
174            2 => Ok(Self::TrustedCrls),
175            4 => Ok(Self::IssuerCertificates),
176            8 => Ok(Self::IssuerCrls),
177            15 => Ok(Self::All),
178            v => {
179                error!("Invalid value {} for enum TrustListMasks", v);
180                Err(StatusCode::BadUnexpectedError)
181            }
182        }
183    }
184}
185
186#[derive(Debug, Copy, Clone, PartialEq)]
187pub enum PubSubState {
188    Disabled = 0,
189    Paused = 1,
190    Operational = 2,
191    Error = 3,
192}
193
194impl BinaryEncoder<PubSubState> for PubSubState {
195    fn byte_len(&self) -> usize {
196        4
197    }
198
199    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
200        write_i32(stream, *self as i32)
201    }
202
203    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
204        let value = read_i32(stream)?;
205        match value {
206            0 => Ok(Self::Disabled),
207            1 => Ok(Self::Paused),
208            2 => Ok(Self::Operational),
209            3 => Ok(Self::Error),
210            v => {
211                error!("Invalid value {} for enum PubSubState", v);
212                Err(StatusCode::BadUnexpectedError)
213            }
214        }
215    }
216}
217
218bitflags! {
219    pub struct DataSetFieldFlags: i16 {
220        const None = 0;
221        const PromotedField = 1;
222    }
223}
224
225impl BinaryEncoder<DataSetFieldFlags> for DataSetFieldFlags {
226    fn byte_len(&self) -> usize {
227        2
228    }
229
230    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
231        write_i16(stream, self.bits)
232    }
233
234    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
235        Ok(DataSetFieldFlags::from_bits_truncate(i16::decode(stream, decoding_options)?))
236    }
237}
238
239
240bitflags! {
241    pub struct DataSetFieldContentMask: i32 {
242        const None = 0;
243        const StatusCode = 1;
244        const SourceTimestamp = 2;
245        const ServerTimestamp = 4;
246        const SourcePicoSeconds = 8;
247        const ServerPicoSeconds = 16;
248        const RawData = 32;
249    }
250}
251
252impl BinaryEncoder<DataSetFieldContentMask> for DataSetFieldContentMask {
253    fn byte_len(&self) -> usize {
254        4
255    }
256
257    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
258        write_i32(stream, self.bits)
259    }
260
261    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
262        Ok(DataSetFieldContentMask::from_bits_truncate(i32::decode(stream, decoding_options)?))
263    }
264}
265
266
267#[derive(Debug, Copy, Clone, PartialEq)]
268pub enum OverrideValueHandling {
269    Disabled = 0,
270    LastUsableValue = 1,
271    OverrideValue = 2,
272}
273
274impl BinaryEncoder<OverrideValueHandling> for OverrideValueHandling {
275    fn byte_len(&self) -> usize {
276        4
277    }
278
279    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
280        write_i32(stream, *self as i32)
281    }
282
283    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
284        let value = read_i32(stream)?;
285        match value {
286            0 => Ok(Self::Disabled),
287            1 => Ok(Self::LastUsableValue),
288            2 => Ok(Self::OverrideValue),
289            v => {
290                error!("Invalid value {} for enum OverrideValueHandling", v);
291                Err(StatusCode::BadUnexpectedError)
292            }
293        }
294    }
295}
296
297#[derive(Debug, Copy, Clone, PartialEq)]
298pub enum DataSetOrderingType {
299    Undefined = 0,
300    AscendingWriterId = 1,
301    AscendingWriterIdSingle = 2,
302}
303
304impl BinaryEncoder<DataSetOrderingType> for DataSetOrderingType {
305    fn byte_len(&self) -> usize {
306        4
307    }
308
309    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
310        write_i32(stream, *self as i32)
311    }
312
313    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
314        let value = read_i32(stream)?;
315        match value {
316            0 => Ok(Self::Undefined),
317            1 => Ok(Self::AscendingWriterId),
318            2 => Ok(Self::AscendingWriterIdSingle),
319            v => {
320                error!("Invalid value {} for enum DataSetOrderingType", v);
321                Err(StatusCode::BadUnexpectedError)
322            }
323        }
324    }
325}
326
327bitflags! {
328    pub struct UadpNetworkMessageContentMask: i32 {
329        const None = 0;
330        const PublisherId = 1;
331        const GroupHeader = 2;
332        const WriterGroupId = 4;
333        const GroupVersion = 8;
334        const NetworkMessageNumber = 16;
335        const SequenceNumber = 32;
336        const PayloadHeader = 64;
337        const Timestamp = 128;
338        const PicoSeconds = 256;
339        const DataSetClassId = 512;
340        const PromotedFields = 1024;
341    }
342}
343
344impl BinaryEncoder<UadpNetworkMessageContentMask> for UadpNetworkMessageContentMask {
345    fn byte_len(&self) -> usize {
346        4
347    }
348
349    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
350        write_i32(stream, self.bits)
351    }
352
353    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
354        Ok(UadpNetworkMessageContentMask::from_bits_truncate(i32::decode(stream, decoding_options)?))
355    }
356}
357
358
359bitflags! {
360    pub struct UadpDataSetMessageContentMask: i32 {
361        const None = 0;
362        const Timestamp = 1;
363        const PicoSeconds = 2;
364        const Status = 4;
365        const MajorVersion = 8;
366        const MinorVersion = 16;
367        const SequenceNumber = 32;
368    }
369}
370
371impl BinaryEncoder<UadpDataSetMessageContentMask> for UadpDataSetMessageContentMask {
372    fn byte_len(&self) -> usize {
373        4
374    }
375
376    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
377        write_i32(stream, self.bits)
378    }
379
380    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
381        Ok(UadpDataSetMessageContentMask::from_bits_truncate(i32::decode(stream, decoding_options)?))
382    }
383}
384
385
386bitflags! {
387    pub struct JsonNetworkMessageContentMask: i32 {
388        const None = 0;
389        const NetworkMessageHeader = 1;
390        const DataSetMessageHeader = 2;
391        const SingleDataSetMessage = 4;
392        const PublisherId = 8;
393        const DataSetClassId = 16;
394        const ReplyTo = 32;
395    }
396}
397
398impl BinaryEncoder<JsonNetworkMessageContentMask> for JsonNetworkMessageContentMask {
399    fn byte_len(&self) -> usize {
400        4
401    }
402
403    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
404        write_i32(stream, self.bits)
405    }
406
407    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
408        Ok(JsonNetworkMessageContentMask::from_bits_truncate(i32::decode(stream, decoding_options)?))
409    }
410}
411
412
413bitflags! {
414    pub struct JsonDataSetMessageContentMask: i32 {
415        const None = 0;
416        const DataSetWriterId = 1;
417        const MetaDataVersion = 2;
418        const SequenceNumber = 4;
419        const Timestamp = 8;
420        const Status = 16;
421    }
422}
423
424impl BinaryEncoder<JsonDataSetMessageContentMask> for JsonDataSetMessageContentMask {
425    fn byte_len(&self) -> usize {
426        4
427    }
428
429    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
430        write_i32(stream, self.bits)
431    }
432
433    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
434        Ok(JsonDataSetMessageContentMask::from_bits_truncate(i32::decode(stream, decoding_options)?))
435    }
436}
437
438
439#[derive(Debug, Copy, Clone, PartialEq)]
440pub enum BrokerTransportQualityOfService {
441    NotSpecified = 0,
442    BestEffort = 1,
443    AtLeastOnce = 2,
444    AtMostOnce = 3,
445    ExactlyOnce = 4,
446}
447
448impl BinaryEncoder<BrokerTransportQualityOfService> for BrokerTransportQualityOfService {
449    fn byte_len(&self) -> usize {
450        4
451    }
452
453    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
454        write_i32(stream, *self as i32)
455    }
456
457    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
458        let value = read_i32(stream)?;
459        match value {
460            0 => Ok(Self::NotSpecified),
461            1 => Ok(Self::BestEffort),
462            2 => Ok(Self::AtLeastOnce),
463            3 => Ok(Self::AtMostOnce),
464            4 => Ok(Self::ExactlyOnce),
465            v => {
466                error!("Invalid value {} for enum BrokerTransportQualityOfService", v);
467                Err(StatusCode::BadUnexpectedError)
468            }
469        }
470    }
471}
472
473#[derive(Debug, Copy, Clone, PartialEq)]
474pub enum DiagnosticsLevel {
475    Basic = 0,
476    Advanced = 1,
477    Info = 2,
478    Log = 3,
479    Debug = 4,
480}
481
482impl BinaryEncoder<DiagnosticsLevel> for DiagnosticsLevel {
483    fn byte_len(&self) -> usize {
484        4
485    }
486
487    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
488        write_i32(stream, *self as i32)
489    }
490
491    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
492        let value = read_i32(stream)?;
493        match value {
494            0 => Ok(Self::Basic),
495            1 => Ok(Self::Advanced),
496            2 => Ok(Self::Info),
497            3 => Ok(Self::Log),
498            4 => Ok(Self::Debug),
499            v => {
500                error!("Invalid value {} for enum DiagnosticsLevel", v);
501                Err(StatusCode::BadUnexpectedError)
502            }
503        }
504    }
505}
506
507#[derive(Debug, Copy, Clone, PartialEq)]
508pub enum PubSubDiagnosticsCounterClassification {
509    Information = 0,
510    Error = 1,
511}
512
513impl BinaryEncoder<PubSubDiagnosticsCounterClassification> for PubSubDiagnosticsCounterClassification {
514    fn byte_len(&self) -> usize {
515        4
516    }
517
518    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
519        write_i32(stream, *self as i32)
520    }
521
522    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
523        let value = read_i32(stream)?;
524        match value {
525            0 => Ok(Self::Information),
526            1 => Ok(Self::Error),
527            v => {
528                error!("Invalid value {} for enum PubSubDiagnosticsCounterClassification", v);
529                Err(StatusCode::BadUnexpectedError)
530            }
531        }
532    }
533}
534
535#[derive(Debug, Copy, Clone, PartialEq)]
536pub enum IdType {
537    Numeric = 0,
538    String = 1,
539    Guid = 2,
540    Opaque = 3,
541}
542
543impl BinaryEncoder<IdType> for IdType {
544    fn byte_len(&self) -> usize {
545        4
546    }
547
548    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
549        write_i32(stream, *self as i32)
550    }
551
552    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
553        let value = read_i32(stream)?;
554        match value {
555            0 => Ok(Self::Numeric),
556            1 => Ok(Self::String),
557            2 => Ok(Self::Guid),
558            3 => Ok(Self::Opaque),
559            v => {
560                error!("Invalid value {} for enum IdType", v);
561                Err(StatusCode::BadUnexpectedError)
562            }
563        }
564    }
565}
566
567#[derive(Debug, Copy, Clone, PartialEq)]
568pub enum NodeClass {
569    Unspecified = 0,
570    Object = 1,
571    Variable = 2,
572    Method = 4,
573    ObjectType = 8,
574    VariableType = 16,
575    ReferenceType = 32,
576    DataType = 64,
577    View = 128,
578}
579
580impl BinaryEncoder<NodeClass> for NodeClass {
581    fn byte_len(&self) -> usize {
582        4
583    }
584
585    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
586        write_i32(stream, *self as i32)
587    }
588
589    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
590        let value = read_i32(stream)?;
591        match value {
592            0 => Ok(Self::Unspecified),
593            1 => Ok(Self::Object),
594            2 => Ok(Self::Variable),
595            4 => Ok(Self::Method),
596            8 => Ok(Self::ObjectType),
597            16 => Ok(Self::VariableType),
598            32 => Ok(Self::ReferenceType),
599            64 => Ok(Self::DataType),
600            128 => Ok(Self::View),
601            v => {
602                error!("Invalid value {} for enum NodeClass", v);
603                Err(StatusCode::BadUnexpectedError)
604            }
605        }
606    }
607}
608
609bitflags! {
610    pub struct PermissionType: i32 {
611        const None = 0;
612        const Browse = 1;
613        const ReadRolePermissions = 2;
614        const WriteAttribute = 4;
615        const WriteRolePermissions = 8;
616        const WriteHistorizing = 16;
617        const Read = 32;
618        const Write = 64;
619        const ReadHistory = 128;
620        const InsertHistory = 256;
621        const ModifyHistory = 512;
622        const DeleteHistory = 1024;
623        const ReceiveEvents = 2048;
624        const Call = 4096;
625        const AddReference = 8192;
626        const RemoveReference = 16384;
627        const DeleteNode = 32768;
628        const AddNode = 65536;
629    }
630}
631
632impl BinaryEncoder<PermissionType> for PermissionType {
633    fn byte_len(&self) -> usize {
634        4
635    }
636
637    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
638        write_i32(stream, self.bits)
639    }
640
641    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
642        Ok(PermissionType::from_bits_truncate(i32::decode(stream, decoding_options)?))
643    }
644}
645
646
647bitflags! {
648    pub struct AccessLevelType: u8 {
649        const None = 0;
650        const CurrentRead = 1;
651        const CurrentWrite = 2;
652        const HistoryRead = 4;
653        const HistoryWrite = 8;
654        const SemanticChange = 16;
655        const StatusWrite = 32;
656        const TimestampWrite = 64;
657    }
658}
659
660impl BinaryEncoder<AccessLevelType> for AccessLevelType {
661    fn byte_len(&self) -> usize {
662        1
663    }
664
665    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
666        write_u8(stream, self.bits)
667    }
668
669    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
670        Ok(AccessLevelType::from_bits_truncate(u8::decode(stream, decoding_options)?))
671    }
672}
673
674
675bitflags! {
676    pub struct AccessLevelExType: i32 {
677        const None = 0;
678        const CurrentRead = 1;
679        const CurrentWrite = 2;
680        const HistoryRead = 4;
681        const HistoryWrite = 8;
682        const SemanticChange = 16;
683        const StatusWrite = 32;
684        const TimestampWrite = 64;
685        const NonatomicRead = 256;
686        const NonatomicWrite = 512;
687        const WriteFullArrayOnly = 1024;
688        const NoSubDataTypes = 2048;
689    }
690}
691
692impl BinaryEncoder<AccessLevelExType> for AccessLevelExType {
693    fn byte_len(&self) -> usize {
694        4
695    }
696
697    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
698        write_i32(stream, self.bits)
699    }
700
701    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
702        Ok(AccessLevelExType::from_bits_truncate(i32::decode(stream, decoding_options)?))
703    }
704}
705
706
707bitflags! {
708    pub struct EventNotifierType: u8 {
709        const None = 0;
710        const SubscribeToEvents = 1;
711        const HistoryRead = 4;
712        const HistoryWrite = 8;
713    }
714}
715
716impl BinaryEncoder<EventNotifierType> for EventNotifierType {
717    fn byte_len(&self) -> usize {
718        1
719    }
720
721    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
722        write_u8(stream, self.bits)
723    }
724
725    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
726        Ok(EventNotifierType::from_bits_truncate(u8::decode(stream, decoding_options)?))
727    }
728}
729
730
731bitflags! {
732    pub struct AccessRestrictionType: i16 {
733        const None = 0;
734        const SigningRequired = 1;
735        const EncryptionRequired = 2;
736        const SessionRequired = 4;
737        const ApplyRestrictionsToBrowse = 8;
738    }
739}
740
741impl BinaryEncoder<AccessRestrictionType> for AccessRestrictionType {
742    fn byte_len(&self) -> usize {
743        2
744    }
745
746    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
747        write_i16(stream, self.bits)
748    }
749
750    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
751        Ok(AccessRestrictionType::from_bits_truncate(i16::decode(stream, decoding_options)?))
752    }
753}
754
755
756#[derive(Debug, Copy, Clone, PartialEq)]
757pub enum StructureType {
758    Structure = 0,
759    StructureWithOptionalFields = 1,
760    Union = 2,
761}
762
763impl BinaryEncoder<StructureType> for StructureType {
764    fn byte_len(&self) -> usize {
765        4
766    }
767
768    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
769        write_i32(stream, *self as i32)
770    }
771
772    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
773        let value = read_i32(stream)?;
774        match value {
775            0 => Ok(Self::Structure),
776            1 => Ok(Self::StructureWithOptionalFields),
777            2 => Ok(Self::Union),
778            v => {
779                error!("Invalid value {} for enum StructureType", v);
780                Err(StatusCode::BadUnexpectedError)
781            }
782        }
783    }
784}
785
786#[derive(Debug, Copy, Clone, PartialEq)]
787pub enum ApplicationType {
788    Server = 0,
789    Client = 1,
790    ClientAndServer = 2,
791    DiscoveryServer = 3,
792}
793
794impl BinaryEncoder<ApplicationType> for ApplicationType {
795    fn byte_len(&self) -> usize {
796        4
797    }
798
799    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
800        write_i32(stream, *self as i32)
801    }
802
803    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
804        let value = read_i32(stream)?;
805        match value {
806            0 => Ok(Self::Server),
807            1 => Ok(Self::Client),
808            2 => Ok(Self::ClientAndServer),
809            3 => Ok(Self::DiscoveryServer),
810            v => {
811                error!("Invalid value {} for enum ApplicationType", v);
812                Err(StatusCode::BadUnexpectedError)
813            }
814        }
815    }
816}
817
818#[derive(Debug, Copy, Clone, PartialEq)]
819pub enum MessageSecurityMode {
820    Invalid = 0,
821    None = 1,
822    Sign = 2,
823    SignAndEncrypt = 3,
824}
825
826impl BinaryEncoder<MessageSecurityMode> for MessageSecurityMode {
827    fn byte_len(&self) -> usize {
828        4
829    }
830
831    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
832        write_i32(stream, *self as i32)
833    }
834
835    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
836        let value = read_i32(stream)?;
837        match value {
838            0 => Ok(Self::Invalid),
839            1 => Ok(Self::None),
840            2 => Ok(Self::Sign),
841            3 => Ok(Self::SignAndEncrypt),
842            v => {
843                error!("Invalid value {} for enum MessageSecurityMode", v);
844                Err(StatusCode::BadUnexpectedError)
845            }
846        }
847    }
848}
849
850#[derive(Debug, Copy, Clone, PartialEq)]
851pub enum UserTokenType {
852    Anonymous = 0,
853    UserName = 1,
854    Certificate = 2,
855    IssuedToken = 3,
856}
857
858impl BinaryEncoder<UserTokenType> for UserTokenType {
859    fn byte_len(&self) -> usize {
860        4
861    }
862
863    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
864        write_i32(stream, *self as i32)
865    }
866
867    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
868        let value = read_i32(stream)?;
869        match value {
870            0 => Ok(Self::Anonymous),
871            1 => Ok(Self::UserName),
872            2 => Ok(Self::Certificate),
873            3 => Ok(Self::IssuedToken),
874            v => {
875                error!("Invalid value {} for enum UserTokenType", v);
876                Err(StatusCode::BadUnexpectedError)
877            }
878        }
879    }
880}
881
882#[derive(Debug, Copy, Clone, PartialEq)]
883pub enum SecurityTokenRequestType {
884    Issue = 0,
885    Renew = 1,
886}
887
888impl BinaryEncoder<SecurityTokenRequestType> for SecurityTokenRequestType {
889    fn byte_len(&self) -> usize {
890        4
891    }
892
893    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
894        write_i32(stream, *self as i32)
895    }
896
897    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
898        let value = read_i32(stream)?;
899        match value {
900            0 => Ok(Self::Issue),
901            1 => Ok(Self::Renew),
902            v => {
903                error!("Invalid value {} for enum SecurityTokenRequestType", v);
904                Err(StatusCode::BadUnexpectedError)
905            }
906        }
907    }
908}
909
910#[derive(Debug, Copy, Clone, PartialEq)]
911pub enum NodeAttributesMask {
912    None = 0,
913    AccessLevel = 1,
914    ArrayDimensions = 2,
915    BrowseName = 4,
916    ContainsNoLoops = 8,
917    DataType = 16,
918    Description = 32,
919    DisplayName = 64,
920    EventNotifier = 128,
921    Executable = 256,
922    Historizing = 512,
923    InverseName = 1024,
924    IsAbstract = 2048,
925    MinimumSamplingInterval = 4096,
926    NodeClass = 8192,
927    NodeId = 16384,
928    Symmetric = 32768,
929    UserAccessLevel = 65536,
930    UserExecutable = 131072,
931    UserWriteMask = 262144,
932    ValueRank = 524288,
933    WriteMask = 1048576,
934    Value = 2097152,
935    DataTypeDefinition = 4194304,
936    RolePermissions = 8388608,
937    AccessRestrictions = 16777216,
938    All = 33554431,
939    BaseNode = 26501220,
940    Object = 26501348,
941    ObjectType = 26503268,
942    Variable = 26571383,
943    VariableType = 28600438,
944    Method = 26632548,
945    ReferenceType = 26537060,
946    View = 26501356,
947}
948
949impl BinaryEncoder<NodeAttributesMask> for NodeAttributesMask {
950    fn byte_len(&self) -> usize {
951        4
952    }
953
954    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
955        write_i32(stream, *self as i32)
956    }
957
958    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
959        let value = read_i32(stream)?;
960        match value {
961            0 => Ok(Self::None),
962            1 => Ok(Self::AccessLevel),
963            2 => Ok(Self::ArrayDimensions),
964            4 => Ok(Self::BrowseName),
965            8 => Ok(Self::ContainsNoLoops),
966            16 => Ok(Self::DataType),
967            32 => Ok(Self::Description),
968            64 => Ok(Self::DisplayName),
969            128 => Ok(Self::EventNotifier),
970            256 => Ok(Self::Executable),
971            512 => Ok(Self::Historizing),
972            1024 => Ok(Self::InverseName),
973            2048 => Ok(Self::IsAbstract),
974            4096 => Ok(Self::MinimumSamplingInterval),
975            8192 => Ok(Self::NodeClass),
976            16384 => Ok(Self::NodeId),
977            32768 => Ok(Self::Symmetric),
978            65536 => Ok(Self::UserAccessLevel),
979            131072 => Ok(Self::UserExecutable),
980            262144 => Ok(Self::UserWriteMask),
981            524288 => Ok(Self::ValueRank),
982            1048576 => Ok(Self::WriteMask),
983            2097152 => Ok(Self::Value),
984            4194304 => Ok(Self::DataTypeDefinition),
985            8388608 => Ok(Self::RolePermissions),
986            16777216 => Ok(Self::AccessRestrictions),
987            33554431 => Ok(Self::All),
988            26501220 => Ok(Self::BaseNode),
989            26501348 => Ok(Self::Object),
990            26503268 => Ok(Self::ObjectType),
991            26571383 => Ok(Self::Variable),
992            28600438 => Ok(Self::VariableType),
993            26632548 => Ok(Self::Method),
994            26537060 => Ok(Self::ReferenceType),
995            26501356 => Ok(Self::View),
996            v => {
997                error!("Invalid value {} for enum NodeAttributesMask", v);
998                Err(StatusCode::BadUnexpectedError)
999            }
1000        }
1001    }
1002}
1003
1004bitflags! {
1005    pub struct AttributeWriteMask: i32 {
1006        const None = 0;
1007        const AccessLevel = 1;
1008        const ArrayDimensions = 2;
1009        const BrowseName = 4;
1010        const ContainsNoLoops = 8;
1011        const DataType = 16;
1012        const Description = 32;
1013        const DisplayName = 64;
1014        const EventNotifier = 128;
1015        const Executable = 256;
1016        const Historizing = 512;
1017        const InverseName = 1024;
1018        const IsAbstract = 2048;
1019        const MinimumSamplingInterval = 4096;
1020        const NodeClass = 8192;
1021        const NodeId = 16384;
1022        const Symmetric = 32768;
1023        const UserAccessLevel = 65536;
1024        const UserExecutable = 131072;
1025        const UserWriteMask = 262144;
1026        const ValueRank = 524288;
1027        const WriteMask = 1048576;
1028        const ValueForVariableType = 2097152;
1029        const DataTypeDefinition = 4194304;
1030        const RolePermissions = 8388608;
1031        const AccessRestrictions = 16777216;
1032        const AccessLevelEx = 33554432;
1033    }
1034}
1035
1036impl BinaryEncoder<AttributeWriteMask> for AttributeWriteMask {
1037    fn byte_len(&self) -> usize {
1038        4
1039    }
1040
1041    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1042        write_i32(stream, self.bits)
1043    }
1044
1045    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
1046        Ok(AttributeWriteMask::from_bits_truncate(i32::decode(stream, decoding_options)?))
1047    }
1048}
1049
1050
1051#[derive(Debug, Copy, Clone, PartialEq)]
1052pub enum BrowseDirection {
1053    Forward = 0,
1054    Inverse = 1,
1055    Both = 2,
1056    Invalid = 3,
1057}
1058
1059impl BinaryEncoder<BrowseDirection> for BrowseDirection {
1060    fn byte_len(&self) -> usize {
1061        4
1062    }
1063
1064    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1065        write_i32(stream, *self as i32)
1066    }
1067
1068    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1069        let value = read_i32(stream)?;
1070        match value {
1071            0 => Ok(Self::Forward),
1072            1 => Ok(Self::Inverse),
1073            2 => Ok(Self::Both),
1074            3 => Ok(Self::Invalid),
1075            v => {
1076                error!("Invalid value {} for enum BrowseDirection", v);
1077                Ok(Self::Invalid)
1078            }
1079        }
1080    }
1081}
1082
1083#[derive(Debug, Copy, Clone, PartialEq)]
1084pub enum BrowseResultMask {
1085    None = 0,
1086    ReferenceTypeId = 1,
1087    IsForward = 2,
1088    NodeClass = 4,
1089    BrowseName = 8,
1090    DisplayName = 16,
1091    TypeDefinition = 32,
1092    All = 63,
1093    ReferenceTypeInfo = 3,
1094    TargetInfo = 60,
1095}
1096
1097impl BinaryEncoder<BrowseResultMask> for BrowseResultMask {
1098    fn byte_len(&self) -> usize {
1099        4
1100    }
1101
1102    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1103        write_i32(stream, *self as i32)
1104    }
1105
1106    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1107        let value = read_i32(stream)?;
1108        match value {
1109            0 => Ok(Self::None),
1110            1 => Ok(Self::ReferenceTypeId),
1111            2 => Ok(Self::IsForward),
1112            4 => Ok(Self::NodeClass),
1113            8 => Ok(Self::BrowseName),
1114            16 => Ok(Self::DisplayName),
1115            32 => Ok(Self::TypeDefinition),
1116            63 => Ok(Self::All),
1117            3 => Ok(Self::ReferenceTypeInfo),
1118            60 => Ok(Self::TargetInfo),
1119            v => {
1120                error!("Invalid value {} for enum BrowseResultMask", v);
1121                Err(StatusCode::BadUnexpectedError)
1122            }
1123        }
1124    }
1125}
1126
1127#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
1128pub enum FilterOperator {
1129    Equals = 0,
1130    IsNull = 1,
1131    GreaterThan = 2,
1132    LessThan = 3,
1133    GreaterThanOrEqual = 4,
1134    LessThanOrEqual = 5,
1135    Like = 6,
1136    Not = 7,
1137    Between = 8,
1138    InList = 9,
1139    And = 10,
1140    Or = 11,
1141    Cast = 12,
1142    InView = 13,
1143    OfType = 14,
1144    RelatedTo = 15,
1145    BitwiseAnd = 16,
1146    BitwiseOr = 17,
1147}
1148
1149impl BinaryEncoder<FilterOperator> for FilterOperator {
1150    fn byte_len(&self) -> usize {
1151        4
1152    }
1153
1154    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1155        write_i32(stream, *self as i32)
1156    }
1157
1158    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1159        let value = read_i32(stream)?;
1160        match value {
1161            0 => Ok(Self::Equals),
1162            1 => Ok(Self::IsNull),
1163            2 => Ok(Self::GreaterThan),
1164            3 => Ok(Self::LessThan),
1165            4 => Ok(Self::GreaterThanOrEqual),
1166            5 => Ok(Self::LessThanOrEqual),
1167            6 => Ok(Self::Like),
1168            7 => Ok(Self::Not),
1169            8 => Ok(Self::Between),
1170            9 => Ok(Self::InList),
1171            10 => Ok(Self::And),
1172            11 => Ok(Self::Or),
1173            12 => Ok(Self::Cast),
1174            13 => Ok(Self::InView),
1175            14 => Ok(Self::OfType),
1176            15 => Ok(Self::RelatedTo),
1177            16 => Ok(Self::BitwiseAnd),
1178            17 => Ok(Self::BitwiseOr),
1179            v => {
1180                error!("Invalid value {} for enum FilterOperator", v);
1181                Err(StatusCode::BadUnexpectedError)
1182            }
1183        }
1184    }
1185}
1186
1187#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
1188pub enum TimestampsToReturn {
1189    Source = 0,
1190    Server = 1,
1191    Both = 2,
1192    Neither = 3,
1193    Invalid = 4,
1194}
1195
1196impl BinaryEncoder<TimestampsToReturn> for TimestampsToReturn {
1197    fn byte_len(&self) -> usize {
1198        4
1199    }
1200
1201    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1202        write_i32(stream, *self as i32)
1203    }
1204
1205    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1206        let value = read_i32(stream)?;
1207        match value {
1208            0 => Ok(Self::Source),
1209            1 => Ok(Self::Server),
1210            2 => Ok(Self::Both),
1211            3 => Ok(Self::Neither),
1212            4 => Ok(Self::Invalid),
1213            v => {
1214                error!("Invalid value {} for enum TimestampsToReturn", v);
1215                Ok(Self::Invalid)
1216            }
1217        }
1218    }
1219}
1220
1221#[derive(Debug, Copy, Clone, PartialEq)]
1222pub enum HistoryUpdateType {
1223    Insert = 1,
1224    Replace = 2,
1225    Update = 3,
1226    Delete = 4,
1227}
1228
1229impl BinaryEncoder<HistoryUpdateType> for HistoryUpdateType {
1230    fn byte_len(&self) -> usize {
1231        4
1232    }
1233
1234    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1235        write_i32(stream, *self as i32)
1236    }
1237
1238    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1239        let value = read_i32(stream)?;
1240        match value {
1241            1 => Ok(Self::Insert),
1242            2 => Ok(Self::Replace),
1243            3 => Ok(Self::Update),
1244            4 => Ok(Self::Delete),
1245            v => {
1246                error!("Invalid value {} for enum HistoryUpdateType", v);
1247                Err(StatusCode::BadUnexpectedError)
1248            }
1249        }
1250    }
1251}
1252
1253#[derive(Debug, Copy, Clone, PartialEq)]
1254pub enum PerformUpdateType {
1255    Insert = 1,
1256    Replace = 2,
1257    Update = 3,
1258    Remove = 4,
1259}
1260
1261impl BinaryEncoder<PerformUpdateType> for PerformUpdateType {
1262    fn byte_len(&self) -> usize {
1263        4
1264    }
1265
1266    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1267        write_i32(stream, *self as i32)
1268    }
1269
1270    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1271        let value = read_i32(stream)?;
1272        match value {
1273            1 => Ok(Self::Insert),
1274            2 => Ok(Self::Replace),
1275            3 => Ok(Self::Update),
1276            4 => Ok(Self::Remove),
1277            v => {
1278                error!("Invalid value {} for enum PerformUpdateType", v);
1279                Err(StatusCode::BadUnexpectedError)
1280            }
1281        }
1282    }
1283}
1284
1285#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
1286pub enum MonitoringMode {
1287    Disabled = 0,
1288    Sampling = 1,
1289    Reporting = 2,
1290}
1291
1292impl BinaryEncoder<MonitoringMode> for MonitoringMode {
1293    fn byte_len(&self) -> usize {
1294        4
1295    }
1296
1297    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1298        write_i32(stream, *self as i32)
1299    }
1300
1301    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1302        let value = read_i32(stream)?;
1303        match value {
1304            0 => Ok(Self::Disabled),
1305            1 => Ok(Self::Sampling),
1306            2 => Ok(Self::Reporting),
1307            v => {
1308                error!("Invalid value {} for enum MonitoringMode", v);
1309                Err(StatusCode::BadUnexpectedError)
1310            }
1311        }
1312    }
1313}
1314
1315#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
1316pub enum DataChangeTrigger {
1317    Status = 0,
1318    StatusValue = 1,
1319    StatusValueTimestamp = 2,
1320}
1321
1322impl BinaryEncoder<DataChangeTrigger> for DataChangeTrigger {
1323    fn byte_len(&self) -> usize {
1324        4
1325    }
1326
1327    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1328        write_i32(stream, *self as i32)
1329    }
1330
1331    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1332        let value = read_i32(stream)?;
1333        match value {
1334            0 => Ok(Self::Status),
1335            1 => Ok(Self::StatusValue),
1336            2 => Ok(Self::StatusValueTimestamp),
1337            v => {
1338                error!("Invalid value {} for enum DataChangeTrigger", v);
1339                Err(StatusCode::BadUnexpectedError)
1340            }
1341        }
1342    }
1343}
1344
1345#[derive(Debug, Copy, Clone, PartialEq)]
1346pub enum DeadbandType {
1347    None = 0,
1348    Absolute = 1,
1349    Percent = 2,
1350}
1351
1352impl BinaryEncoder<DeadbandType> for DeadbandType {
1353    fn byte_len(&self) -> usize {
1354        4
1355    }
1356
1357    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1358        write_i32(stream, *self as i32)
1359    }
1360
1361    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1362        let value = read_i32(stream)?;
1363        match value {
1364            0 => Ok(Self::None),
1365            1 => Ok(Self::Absolute),
1366            2 => Ok(Self::Percent),
1367            v => {
1368                error!("Invalid value {} for enum DeadbandType", v);
1369                Err(StatusCode::BadUnexpectedError)
1370            }
1371        }
1372    }
1373}
1374
1375#[derive(Debug, Copy, Clone, PartialEq)]
1376pub enum RedundancySupport {
1377    None = 0,
1378    Cold = 1,
1379    Warm = 2,
1380    Hot = 3,
1381    Transparent = 4,
1382    HotAndMirrored = 5,
1383}
1384
1385impl BinaryEncoder<RedundancySupport> for RedundancySupport {
1386    fn byte_len(&self) -> usize {
1387        4
1388    }
1389
1390    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1391        write_i32(stream, *self as i32)
1392    }
1393
1394    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1395        let value = read_i32(stream)?;
1396        match value {
1397            0 => Ok(Self::None),
1398            1 => Ok(Self::Cold),
1399            2 => Ok(Self::Warm),
1400            3 => Ok(Self::Hot),
1401            4 => Ok(Self::Transparent),
1402            5 => Ok(Self::HotAndMirrored),
1403            v => {
1404                error!("Invalid value {} for enum RedundancySupport", v);
1405                Err(StatusCode::BadUnexpectedError)
1406            }
1407        }
1408    }
1409}
1410
1411#[derive(Debug, Copy, Clone, PartialEq)]
1412pub enum ServerState {
1413    Running = 0,
1414    Failed = 1,
1415    NoConfiguration = 2,
1416    Suspended = 3,
1417    Shutdown = 4,
1418    Test = 5,
1419    CommunicationFault = 6,
1420    Unknown = 7,
1421}
1422
1423impl BinaryEncoder<ServerState> for ServerState {
1424    fn byte_len(&self) -> usize {
1425        4
1426    }
1427
1428    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1429        write_i32(stream, *self as i32)
1430    }
1431
1432    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1433        let value = read_i32(stream)?;
1434        match value {
1435            0 => Ok(Self::Running),
1436            1 => Ok(Self::Failed),
1437            2 => Ok(Self::NoConfiguration),
1438            3 => Ok(Self::Suspended),
1439            4 => Ok(Self::Shutdown),
1440            5 => Ok(Self::Test),
1441            6 => Ok(Self::CommunicationFault),
1442            7 => Ok(Self::Unknown),
1443            v => {
1444                error!("Invalid value {} for enum ServerState", v);
1445                Err(StatusCode::BadUnexpectedError)
1446            }
1447        }
1448    }
1449}
1450
1451#[derive(Debug, Copy, Clone, PartialEq)]
1452pub enum ModelChangeStructureVerbMask {
1453    NodeAdded = 1,
1454    NodeDeleted = 2,
1455    ReferenceAdded = 4,
1456    ReferenceDeleted = 8,
1457    DataTypeChanged = 16,
1458}
1459
1460impl BinaryEncoder<ModelChangeStructureVerbMask> for ModelChangeStructureVerbMask {
1461    fn byte_len(&self) -> usize {
1462        4
1463    }
1464
1465    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1466        write_i32(stream, *self as i32)
1467    }
1468
1469    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1470        let value = read_i32(stream)?;
1471        match value {
1472            1 => Ok(Self::NodeAdded),
1473            2 => Ok(Self::NodeDeleted),
1474            4 => Ok(Self::ReferenceAdded),
1475            8 => Ok(Self::ReferenceDeleted),
1476            16 => Ok(Self::DataTypeChanged),
1477            v => {
1478                error!("Invalid value {} for enum ModelChangeStructureVerbMask", v);
1479                Err(StatusCode::BadUnexpectedError)
1480            }
1481        }
1482    }
1483}
1484
1485#[derive(Debug, Copy, Clone, PartialEq)]
1486pub enum AxisScaleEnumeration {
1487    Linear = 0,
1488    Log = 1,
1489    Ln = 2,
1490}
1491
1492impl BinaryEncoder<AxisScaleEnumeration> for AxisScaleEnumeration {
1493    fn byte_len(&self) -> usize {
1494        4
1495    }
1496
1497    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1498        write_i32(stream, *self as i32)
1499    }
1500
1501    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1502        let value = read_i32(stream)?;
1503        match value {
1504            0 => Ok(Self::Linear),
1505            1 => Ok(Self::Log),
1506            2 => Ok(Self::Ln),
1507            v => {
1508                error!("Invalid value {} for enum AxisScaleEnumeration", v);
1509                Err(StatusCode::BadUnexpectedError)
1510            }
1511        }
1512    }
1513}
1514
1515#[derive(Debug, Copy, Clone, PartialEq)]
1516pub enum ExceptionDeviationFormat {
1517    AbsoluteValue = 0,
1518    PercentOfValue = 1,
1519    PercentOfRange = 2,
1520    PercentOfEURange = 3,
1521    Unknown = 4,
1522}
1523
1524impl BinaryEncoder<ExceptionDeviationFormat> for ExceptionDeviationFormat {
1525    fn byte_len(&self) -> usize {
1526        4
1527    }
1528
1529    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
1530        write_i32(stream, *self as i32)
1531    }
1532
1533    fn decode<S: Read>(stream: &mut S, _: &DecodingOptions) -> EncodingResult<Self> {
1534        let value = read_i32(stream)?;
1535        match value {
1536            0 => Ok(Self::AbsoluteValue),
1537            1 => Ok(Self::PercentOfValue),
1538            2 => Ok(Self::PercentOfRange),
1539            3 => Ok(Self::PercentOfEURange),
1540            4 => Ok(Self::Unknown),
1541            v => {
1542                error!("Invalid value {} for enum ExceptionDeviationFormat", v);
1543                Err(StatusCode::BadUnexpectedError)
1544            }
1545        }
1546    }
1547}