opcua-kit 0.0.1

OPC UA utilities for Rust, starting with StatusCode severity classification
Documentation
#![no_std]
#![doc = include_str!("../README.md")]

/// Client interpretation of the severity field of an OPC UA StatusCode.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Severity {
    /// The operation succeeded.
    Good,
    /// The result may be unsuitable for some uses.
    Uncertain,
    /// The operation failed or the severity uses the reserved encoding.
    Bad,
}

/// Classifies the two severity bits, independently of the subcode and flags.
///
/// ```
/// use opcua_kit::{status_severity, Severity};
///
/// assert_eq!(status_severity(0x0000_0000), Severity::Good);
/// assert_eq!(status_severity(0x4000_0000), Severity::Uncertain);
/// assert_eq!(status_severity(0x8000_0000), Severity::Bad);
/// assert_eq!(status_severity(0xFFFF_FFFF), Severity::Bad);
/// ```
pub const fn status_severity(status_code: u32) -> Severity {
    match status_code >> 30 {
        0 => Severity::Good,
        1 => Severity::Uncertain,
        _ => Severity::Bad,
    }
}