Enum opcua_server::prelude::Variant
source · pub enum Variant {
Show 26 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(DateTime),
Guid(Guid),
StatusCode(StatusCode),
ByteString(ByteString),
XmlElement(UAString),
QualifiedName(Box<QualifiedName, Global>),
LocalizedText(Box<LocalizedText, Global>),
NodeId(Box<NodeId, Global>),
ExpandedNodeId(Box<ExpandedNodeId, Global>),
ExtensionObject(Box<ExtensionObject, Global>),
DataValue(Box<DataValue, Global>),
Array(Vec<Variant, Global>),
MultiDimensionArray(Box<MultiDimensionArray, Global>),
}Expand description
A Variant holds all other OPC UA 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
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(DateTime)
DateTime
Guid(Guid)
Guid
StatusCode(StatusCode)
StatusCode
ByteString(ByteString)
ByteString
XmlElement(UAString)
XmlElement
QualifiedName(Box<QualifiedName, Global>)
QualifiedName
LocalizedText(Box<LocalizedText, Global>)
LocalizedText
NodeId(Box<NodeId, Global>)
NodeId
ExpandedNodeId(Box<ExpandedNodeId, Global>)
ExpandedNodeId
ExtensionObject(Box<ExtensionObject, Global>)
ExtensionObject
DataValue(Box<DataValue, Global>)
DataValue (boxed because a DataValue itself holds a Variant)
Array(Vec<Variant, Global>)
Single dimension array A variant can be an array of other kinds (all of which must be the same type), second argument is the dimensions of the array which should match the array length, otherwise BadDecodingError
MultiDimensionArray(Box<MultiDimensionArray, Global>)
Multi dimension array A variant can be an array of other kinds (all of which must be the same type), second argument is the dimensions of the array which should match the array length, otherwise BadDecodingError Higher rank dimensions are serialized first. For example an array with dimensions [2,2,2] is written in this order: [0,0,0], [0,0,1], [0,1,0], [0,1,1], [1,0,0], [1,0,1], [1,1,0], [1,1,1]
Implementations§
source§impl Variant
impl Variant
pub fn new<T>(value: T) -> Variantwhere
T: 'static + Into<Variant>,
sourcepub fn test_encoding_flag(encoding_mask: u8, data_type_id: DataTypeId) -> bool
pub fn test_encoding_flag(encoding_mask: u8, data_type_id: DataTypeId) -> bool
Test the flag (convenience method)
pub fn type_id(&self) -> VariantTypeId
pub fn new_multi_dimension_array(
values: Vec<Variant, Global>,
dimensions: Vec<i32, Global>
) -> Variant
sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Tests and returns true if the variant holds a numeric type
sourcepub fn is_numeric_array(&self) -> bool
pub fn is_numeric_array(&self) -> bool
Tests and returns true if the variant is an array containing numeric values
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 from_i32_array(in_values: &[i32]) -> Variant
pub fn from_u32_array(in_values: &[u32]) -> Variant
pub fn from_string_array(in_values: &[String]) -> Variant
sourcepub fn into_u32_array(&self) -> Result<Vec<u32, Global>, StatusCode>
pub fn into_u32_array(&self) -> Result<Vec<u32, Global>, StatusCode>
Returns an array of UInt32s
pub fn data_type(&self) -> Option<DataTypeId>
Trait Implementations§
source§impl BinaryEncoder<Variant> for Variant
impl BinaryEncoder<Variant> for Variant
source§fn byte_len(&self) -> usize
fn byte_len(&self) -> usize
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_limits: &DecodingLimits
) -> Result<Variant, StatusCode>where
S: Read,
fn decode<S>(
stream: &mut S,
decoding_limits: &DecodingLimits
) -> Result<Variant, StatusCode>where
S: Read,
BadDecodingError as soon as possible. Read morefn to_vec(&self) -> Vec<u8, Global> ⓘ
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 From<ByteString> for Variant
impl From<ByteString> for Variant
source§fn from(v: ByteString) -> Variant
fn from(v: ByteString) -> Variant
source§impl From<ExpandedNodeId> for Variant
impl From<ExpandedNodeId> for Variant
source§fn from(v: ExpandedNodeId) -> Variant
fn from(v: ExpandedNodeId) -> Variant
source§impl From<ExtensionObject> for Variant
impl From<ExtensionObject> for Variant
source§fn from(v: ExtensionObject) -> Variant
fn from(v: ExtensionObject) -> Variant
source§impl From<LocalizedText> for Variant
impl From<LocalizedText> for Variant
source§fn from(v: LocalizedText) -> Variant
fn from(v: LocalizedText) -> Variant
source§impl From<MultiDimensionArray> for Variant
impl From<MultiDimensionArray> for Variant
source§fn from(v: MultiDimensionArray) -> Variant
fn from(v: MultiDimensionArray) -> Variant
source§impl From<QualifiedName> for Variant
impl From<QualifiedName> for Variant
source§fn from(v: QualifiedName) -> Variant
fn from(v: QualifiedName) -> Variant
source§impl From<StatusCode> for Variant
impl From<StatusCode> for Variant
source§fn from(v: StatusCode) -> Variant
fn from(v: StatusCode) -> Variant
source§impl Serialize for Variant
impl Serialize for Variant
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl ToString for Variant
impl ToString for Variant
This implementation is mainly for debugging / convenience purposes, to eliminate some of the noise in common types from using the Debug trait.