// This file was autogenerated from Opc.Ua.Types.bsd.xml by tools/schema/gen_types.js
// DO NOT EDIT THIS FILE

use std::io::{Read, Write};

#[allow(unused_imports)]
use crate::{
    encoding::*,
    basic_types::*,
    service_types::impls::MessageInfo,
    node_ids::ObjectId,
};

#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct ServerDiagnosticsSummaryDataType {
    pub server_view_count: u32,
    pub current_session_count: u32,
    pub cumulated_session_count: u32,
    pub security_rejected_session_count: u32,
    pub rejected_session_count: u32,
    pub session_timeout_count: u32,
    pub session_abort_count: u32,
    pub current_subscription_count: u32,
    pub cumulated_subscription_count: u32,
    pub publishing_interval_count: u32,
    pub security_rejected_requests_count: u32,
    pub rejected_requests_count: u32,
}

impl MessageInfo for ServerDiagnosticsSummaryDataType {
    fn object_id(&self) -> ObjectId {
        ObjectId::ServerDiagnosticsSummaryDataType_Encoding_DefaultBinary
    }
}

impl BinaryEncoder<ServerDiagnosticsSummaryDataType> for ServerDiagnosticsSummaryDataType {
    fn byte_len(&self) -> usize {
        let mut size = 0;
        size += self.server_view_count.byte_len();
        size += self.current_session_count.byte_len();
        size += self.cumulated_session_count.byte_len();
        size += self.security_rejected_session_count.byte_len();
        size += self.rejected_session_count.byte_len();
        size += self.session_timeout_count.byte_len();
        size += self.session_abort_count.byte_len();
        size += self.current_subscription_count.byte_len();
        size += self.cumulated_subscription_count.byte_len();
        size += self.publishing_interval_count.byte_len();
        size += self.security_rejected_requests_count.byte_len();
        size += self.rejected_requests_count.byte_len();
        size
    }

    #[allow(unused_variables)]
    fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize> {
        let mut size = 0;
        size += self.server_view_count.encode(stream)?;
        size += self.current_session_count.encode(stream)?;
        size += self.cumulated_session_count.encode(stream)?;
        size += self.security_rejected_session_count.encode(stream)?;
        size += self.rejected_session_count.encode(stream)?;
        size += self.session_timeout_count.encode(stream)?;
        size += self.session_abort_count.encode(stream)?;
        size += self.current_subscription_count.encode(stream)?;
        size += self.cumulated_subscription_count.encode(stream)?;
        size += self.publishing_interval_count.encode(stream)?;
        size += self.security_rejected_requests_count.encode(stream)?;
        size += self.rejected_requests_count.encode(stream)?;
        Ok(size)
    }

    #[allow(unused_variables)]
    fn decode<S: Read>(stream: &mut S, decoding_limits: &DecodingLimits) -> EncodingResult<Self> {
        let server_view_count = u32::decode(stream, decoding_limits)?;
        let current_session_count = u32::decode(stream, decoding_limits)?;
        let cumulated_session_count = u32::decode(stream, decoding_limits)?;
        let security_rejected_session_count = u32::decode(stream, decoding_limits)?;
        let rejected_session_count = u32::decode(stream, decoding_limits)?;
        let session_timeout_count = u32::decode(stream, decoding_limits)?;
        let session_abort_count = u32::decode(stream, decoding_limits)?;
        let current_subscription_count = u32::decode(stream, decoding_limits)?;
        let cumulated_subscription_count = u32::decode(stream, decoding_limits)?;
        let publishing_interval_count = u32::decode(stream, decoding_limits)?;
        let security_rejected_requests_count = u32::decode(stream, decoding_limits)?;
        let rejected_requests_count = u32::decode(stream, decoding_limits)?;
        Ok(ServerDiagnosticsSummaryDataType {
            server_view_count,
            current_session_count,
            cumulated_session_count,
            security_rejected_session_count,
            rejected_session_count,
            session_timeout_count,
            session_abort_count,
            current_subscription_count,
            cumulated_subscription_count,
            publishing_interval_count,
            security_rejected_requests_count,
            rejected_requests_count,
        })
    }
}
