// OPCUA for Rust
// SPDX-License-Identifier: MPL-2.0
// Copyright (C) 2017-2022 Adam Lock
//
// This file was autogenerated from Opc.Ua.Types.bsd by tools/schema/gen_types.js
//
// DO NOT EDIT THIS FILE
#![allow(unused_attributes)]
use std::io::{Read, Write};
#[allow(unused_imports)]
use crate::types::{
    encoding::*,
    basic_types::*,
    service_types::impls::MessageInfo,
    node_ids::ObjectId,
    service_types::enums::MonitoringMode,
    service_types::ReadValueId,
    service_types::MonitoringParameters,
};

#[derive(Debug, Clone, PartialEq)]
pub struct MonitoredItemCreateRequest {
    pub item_to_monitor: ReadValueId,
    pub monitoring_mode: MonitoringMode,
    pub requested_parameters: MonitoringParameters,
}

impl MessageInfo for MonitoredItemCreateRequest {
    fn object_id(&self) -> ObjectId {
        ObjectId::MonitoredItemCreateRequest_Encoding_DefaultBinary
    }
}

impl BinaryEncoder<MonitoredItemCreateRequest> for MonitoredItemCreateRequest {
    fn byte_len(&self) -> usize {
        let mut size = 0;
        size += self.item_to_monitor.byte_len();
        size += self.monitoring_mode.byte_len();
        size += self.requested_parameters.byte_len();
        size
    }

    #[allow(unused_variables)]
    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
        let mut size = 0;
        size += self.item_to_monitor.encode(stream)?;
        size += self.monitoring_mode.encode(stream)?;
        size += self.requested_parameters.encode(stream)?;
        Ok(size)
    }

    #[allow(unused_variables)]
    fn decode<S: Read>(stream: &mut S, decoding_options: &DecodingOptions) -> EncodingResult<Self> {
        let item_to_monitor = ReadValueId::decode(stream, decoding_options)?;
        let monitoring_mode = MonitoringMode::decode(stream, decoding_options)?;
        let requested_parameters = MonitoringParameters::decode(stream, decoding_options)?;
        Ok(MonitoredItemCreateRequest {
            item_to_monitor,
            monitoring_mode,
            requested_parameters,
        })
    }
}
