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