open62541 0.6.2

High-level, safe bindings for the C99 library open62541, an open source and free implementation of OPC UA (OPC Unified Architecture).
Documentation
use crate::ua;

/// Wrapper for continuation point from [`open62541_sys`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ContinuationPoint(ua::ByteString);

impl ContinuationPoint {
    /// Creates continuation point from raw string.
    ///
    /// This may return [`None`] when the string is invalid (as defined by OPC UA). This is used in
    /// [`ua::BrowseResult`] to indicate that no continuation point was necessary.
    ///
    /// Note: The given string should not be empty.
    #[must_use]
    pub(crate) fn new(continuation_point: ua::ByteString) -> Option<Self> {
        // Unset continuation points indicate that the `BrowseResult` contains all references and no
        // continuation is actually necessary.
        if continuation_point.is_invalid() {
            return None;
        }

        // An empty string would be a strange continuation point. Nothing bad would happen since
        // this is not an invalid string (as defined by OPC UA) but it might indicate an error.
        debug_assert!(!continuation_point.is_empty());

        Some(Self(continuation_point))
    }

    /// Gets underlying representation.
    #[must_use]
    pub(crate) const fn as_byte_string(&self) -> &ua::ByteString {
        &self.0
    }

    /// Gets underlying representation.
    pub(crate) fn to_byte_string(&self) -> ua::ByteString {
        self.0.clone()
    }
}