pub enum Variant {
Show 27 variants
Empty,
Boolean(bool),
SByte(i8),
Byte(u8),
Int16(i16),
UInt16(u16),
Int32(i32),
UInt32(u32),
Int64(i64),
UInt64(u64),
Float(f32),
Double(f64),
String(UAString),
DateTime(Box<DateTime>),
Guid(Box<Guid>),
StatusCode(StatusCode),
ByteString(ByteString),
XmlElement(UAString),
QualifiedName(Box<QualifiedName>),
LocalizedText(Box<LocalizedText>),
NodeId(Box<NodeId>),
ExpandedNodeId(Box<ExpandedNodeId>),
ExtensionObject(Box<ExtensionObject>),
Variant(Box<Variant>),
DataValue(Box<DataValue>),
Diagnostics(Box<DiagnosticInfo>),
Array(Box<Array>),
}Expand description
A Variant holds built-in OPC UA data types, including single and multi dimensional arrays,
data values and extension objects.
As variants may be passed around a lot on the stack, Boxes are used for more complex types to keep the size of this type down a bit, especially when used in arrays.
Variants§
Empty
Empty type has no value. It is equivalent to a Null value (part 6 5.1.6)
Boolean(bool)
Boolean
SByte(i8)
Signed byte
Byte(u8)
Unsigned byte
Int16(i16)
Signed 16-bit int
UInt16(u16)
Unsigned 16-bit int
Int32(i32)
Signed 32-bit int
UInt32(u32)
Unsigned 32-bit int
Int64(i64)
Signed 64-bit int
UInt64(u64)
Unsigned 64-bit int
Float(f32)
Float
Double(f64)
Double
String(UAString)
String
DateTime(Box<DateTime>)
DateTime
Guid(Box<Guid>)
Guid
StatusCode(StatusCode)
StatusCode
ByteString(ByteString)
ByteString
XmlElement(UAString)
XmlElement
QualifiedName(Box<QualifiedName>)
QualifiedName
LocalizedText(Box<LocalizedText>)
LocalizedText
NodeId(Box<NodeId>)
NodeId
ExpandedNodeId(Box<ExpandedNodeId>)
ExpandedNodeId
ExtensionObject(Box<ExtensionObject>)
ExtensionObject
Variant(Box<Variant>)
DataValue(Box<DataValue>)
Diagnostics(Box<DiagnosticInfo>)
Array(Box<Array>)
Single dimension array which can contain any scalar type, all the same type. Nested arrays will be rejected.
Implementations§
Source§impl Variant
impl Variant
Sourcepub fn test_encoding_flag(encoding_mask: u8, flag: u8) -> bool
pub fn test_encoding_flag(encoding_mask: u8, flag: u8) -> bool
Test the flag (convenience method)
Sourcepub fn cast(&self, target_type: VariantTypeId) -> Variant
pub fn cast(&self, target_type: VariantTypeId) -> Variant
Performs an EXPLICIT cast from one type to another. This will first attempt an implicit conversion and only then attempt to cast. Casting is potentially lossy.
Sourcepub fn convert(&self, target_type: VariantTypeId) -> Variant
pub fn convert(&self, target_type: VariantTypeId) -> Variant
Performs an IMPLICIT conversion from one type to another
pub fn type_id(&self) -> VariantTypeId
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Tests and returns true if the variant holds a numeric type
pub fn is_array_of_type(&self, variant_type: VariantTypeId) -> bool
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Tests that the variant is in a valid state. In particular for arrays ensuring that the values are all acceptable and for a multi dimensional array that the dimensions equal the actual values.
pub fn array_data_type(&self) -> Option<NodeId>
pub fn scalar_data_type(&self) -> Option<NodeId>
Sourcepub fn to_byte_array(&self) -> Result<Variant, StatusCode>
pub fn to_byte_array(&self) -> Result<Variant, StatusCode>
This function is for a special edge case of converting a byte string to a single array of bytes
pub fn eq_scalar_type(&self, other: &Variant) -> bool
pub fn eq_array_type(&self, other: &Variant) -> bool
pub fn set_range_of( &mut self, range: NumericRange, other: &Variant, ) -> Result<(), StatusCode>
Sourcepub fn range_of(&self, range: NumericRange) -> Result<Variant, StatusCode>
pub fn range_of(&self, range: NumericRange) -> Result<Variant, StatusCode>
This function gets a range of values from the variant if it is an array, or returns a clone of the variant itself.
Trait Implementations§
Source§impl BinaryEncoder<Variant> for Variant
impl BinaryEncoder<Variant> for Variant
Source§fn byte_len(&self) -> usize
fn byte_len(&self) -> usize
encode were called.
This may be called prior to writing to ensure the correct amount of space is available.Source§fn encode<S>(&self, stream: &mut S) -> Result<usize, StatusCode>where
S: Write,
fn encode<S>(&self, stream: &mut S) -> Result<usize, StatusCode>where
S: Write,
Source§fn decode<S>(
stream: &mut S,
decoding_options: &DecodingOptions,
) -> Result<Variant, StatusCode>where
S: Read,
fn decode<S>(
stream: &mut S,
decoding_options: &DecodingOptions,
) -> Result<Variant, StatusCode>where
S: Read,
BadDecodingError as soon as possible.fn encode_to_vec(&self) -> Vec<u8> ⓘ
Source§impl<'de> Deserialize<'de> for Variant
impl<'de> Deserialize<'de> for Variant
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Variant, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Variant, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for Variant
This implementation is mainly for debugging / convenience purposes, to eliminate some of the
noise in common types from using the Debug trait.
impl Display for Variant
This implementation is mainly for debugging / convenience purposes, to eliminate some of the noise in common types from using the Debug trait.