Variant

Enum Variant 

Source
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

Source

pub fn test_encoding_flag(encoding_mask: u8, flag: u8) -> bool

Test the flag (convenience method)

Source

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.

Source

pub fn convert(&self, target_type: VariantTypeId) -> Variant

Performs an IMPLICIT conversion from one type to another

Source

pub fn type_id(&self) -> VariantTypeId

Source

pub fn is_numeric(&self) -> bool

Tests and returns true if the variant holds a numeric type

Source

pub fn is_array(&self) -> bool

Test if the variant holds an array

Source

pub fn is_array_of_type(&self, variant_type: VariantTypeId) -> bool

Source

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.

Source

pub fn as_f64(&self) -> Option<f64>

Converts the numeric type to a double or returns None

Source

pub fn array_data_type(&self) -> Option<NodeId>

Source

pub fn scalar_data_type(&self) -> Option<NodeId>

Source

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

Source

pub fn eq_scalar_type(&self, other: &Variant) -> bool

Source

pub fn eq_array_type(&self, other: &Variant) -> bool

Source

pub fn set_range_of( &mut self, range: NumericRange, other: &Variant, ) -> Result<(), StatusCode>

Source

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

Source§

fn byte_len(&self) -> usize

Returns the exact byte length of the structure as it would be if 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,

Encodes the instance to the write stream.
Source§

fn decode<S>( stream: &mut S, decoding_options: &DecodingOptions, ) -> Result<Variant, StatusCode>
where S: Read,

Decodes an instance from the read stream. The decoding options contains restrictions set by the server / client on the length of strings, arrays etc. If these limits are exceeded the implementation should return with a BadDecodingError as soon as possible.
Source§

fn encode_to_vec(&self) -> Vec<u8>

Source§

impl Clone for Variant

Source§

fn clone(&self) -> Variant

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Variant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Variant

Source§

fn default() -> Variant

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Variant

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Variant, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
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.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a [String]> for Variant

Source§

fn from(v: &'a [String]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [bool]> for Variant

Source§

fn from(v: &'a [bool]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [f32]> for Variant

Source§

fn from(v: &'a [f32]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [f64]> for Variant

Source§

fn from(v: &'a [f64]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [i16]> for Variant

Source§

fn from(v: &'a [i16]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [i32]> for Variant

Source§

fn from(v: &'a [i32]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [i64]> for Variant

Source§

fn from(v: &'a [i64]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [i8]> for Variant

Source§

fn from(v: &'a [i8]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [u16]> for Variant

Source§

fn from(v: &'a [u16]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [u32]> for Variant

Source§

fn from(v: &'a [u32]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [u64]> for Variant

Source§

fn from(v: &'a [u64]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a [u8]> for Variant

Source§

fn from(v: &'a [u8]) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<String>> for Variant

Source§

fn from(v: &'a Vec<String>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<bool>> for Variant

Source§

fn from(v: &'a Vec<bool>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<f32>> for Variant

Source§

fn from(v: &'a Vec<f32>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<f64>> for Variant

Source§

fn from(v: &'a Vec<f64>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<i16>> for Variant

Source§

fn from(v: &'a Vec<i16>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<i32>> for Variant

Source§

fn from(v: &'a Vec<i32>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<i64>> for Variant

Source§

fn from(v: &'a Vec<i64>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<i8>> for Variant

Source§

fn from(v: &'a Vec<i8>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<u16>> for Variant

Source§

fn from(v: &'a Vec<u16>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<u32>> for Variant

Source§

fn from(v: &'a Vec<u32>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<u64>> for Variant

Source§

fn from(v: &'a Vec<u64>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<u8>> for Variant

Source§

fn from(v: &'a Vec<u8>) -> Variant

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for Variant

Source§

fn from(v: &'a str) -> Variant

Converts to this type from the input type.
Source§

impl From<()> for Variant

Source§

fn from(_: ()) -> Variant

Converts to this type from the input type.
Source§

impl<'a, 'b> From<(VariantTypeId, &'a [&'b str])> for Variant

Source§

fn from(v: (VariantTypeId, &'a [&'b str])) -> Variant

Converts to this type from the input type.
Source§

impl From<(VariantTypeId, Vec<Variant>)> for Variant

Source§

fn from(v: (VariantTypeId, Vec<Variant>)) -> Variant

Converts to this type from the input type.
Source§

impl From<(VariantTypeId, Vec<Variant>, Vec<u32>)> for Variant

Source§

fn from(v: (VariantTypeId, Vec<Variant>, Vec<u32>)) -> Variant

Converts to this type from the input type.
Source§

impl From<Array> for Variant

Source§

fn from(v: Array) -> Variant

Converts to this type from the input type.
Source§

impl From<ByteString> for Variant

Source§

fn from(v: ByteString) -> Variant

Converts to this type from the input type.
Source§

impl From<DataValue> for Variant

Source§

fn from(v: DataValue) -> Variant

Converts to this type from the input type.
Source§

impl From<DateTime> for Variant

Source§

fn from(v: DateTime) -> Variant

Converts to this type from the input type.
Source§

impl From<DiagnosticInfo> for Variant

Source§

fn from(v: DiagnosticInfo) -> Variant

Converts to this type from the input type.
Source§

impl From<ExpandedNodeId> for Variant

Source§

fn from(v: ExpandedNodeId) -> Variant

Converts to this type from the input type.
Source§

impl From<ExtensionObject> for Variant

Source§

fn from(v: ExtensionObject) -> Variant

Converts to this type from the input type.
Source§

impl From<Guid> for Variant

Source§

fn from(v: Guid) -> Variant

Converts to this type from the input type.
Source§

impl From<LocalizedText> for Variant

Source§

fn from(v: LocalizedText) -> Variant

Converts to this type from the input type.
Source§

impl From<NodeId> for Variant

Source§

fn from(v: NodeId) -> Variant

Converts to this type from the input type.
Source§

impl From<QualifiedName> for Variant

Source§

fn from(v: QualifiedName) -> Variant

Converts to this type from the input type.
Source§

impl From<StatusCode> for Variant

Source§

fn from(v: StatusCode) -> Variant

Converts to this type from the input type.
Source§

impl From<String> for Variant

Source§

fn from(v: String) -> Variant

Converts to this type from the input type.
Source§

impl From<UAString> for Variant

Source§

fn from(v: UAString) -> Variant

Converts to this type from the input type.
Source§

impl From<Variant> for DataValue

Source§

fn from(v: Variant) -> DataValue

Converts to this type from the input type.
Source§

impl From<Variant> for LiteralOperand

Source§

fn from(v: Variant) -> LiteralOperand

Converts to this type from the input type.
Source§

impl From<Vec<String>> for Variant

Source§

fn from(v: Vec<String>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<bool>> for Variant

Source§

fn from(v: Vec<bool>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<f32>> for Variant

Source§

fn from(v: Vec<f32>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<f64>> for Variant

Source§

fn from(v: Vec<f64>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<i16>> for Variant

Source§

fn from(v: Vec<i16>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<i32>> for Variant

Source§

fn from(v: Vec<i32>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<i64>> for Variant

Source§

fn from(v: Vec<i64>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<i8>> for Variant

Source§

fn from(v: Vec<i8>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<u16>> for Variant

Source§

fn from(v: Vec<u16>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<u32>> for Variant

Source§

fn from(v: Vec<u32>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<u64>> for Variant

Source§

fn from(v: Vec<u64>) -> Variant

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Variant

Source§

fn from(v: Vec<u8>) -> Variant

Converts to this type from the input type.
Source§

impl From<bool> for Variant

Source§

fn from(v: bool) -> Variant

Converts to this type from the input type.
Source§

impl From<f32> for Variant

Source§

fn from(v: f32) -> Variant

Converts to this type from the input type.
Source§

impl From<f64> for Variant

Source§

fn from(v: f64) -> Variant

Converts to this type from the input type.
Source§

impl From<i16> for Variant

Source§

fn from(v: i16) -> Variant

Converts to this type from the input type.
Source§

impl From<i32> for Variant

Source§

fn from(v: i32) -> Variant

Converts to this type from the input type.
Source§

impl From<i64> for Variant

Source§

fn from(v: i64) -> Variant

Converts to this type from the input type.
Source§

impl From<i8> for Variant

Source§

fn from(v: i8) -> Variant

Converts to this type from the input type.
Source§

impl From<u16> for Variant

Source§

fn from(v: u16) -> Variant

Converts to this type from the input type.
Source§

impl From<u32> for Variant

Source§

fn from(v: u32) -> Variant

Converts to this type from the input type.
Source§

impl From<u64> for Variant

Source§

fn from(v: u64) -> Variant

Converts to this type from the input type.
Source§

impl From<u8> for Variant

Source§

fn from(v: u8) -> Variant

Converts to this type from the input type.
Source§

impl PartialEq for Variant

Source§

fn eq(&self, other: &Variant) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Variant

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&Variant> for Vec<bool>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<bool>, <Vec<bool> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<f32>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<f32>, <Vec<f32> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<f64>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<f64>, <Vec<f64> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<i16>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<i16>, <Vec<i16> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<i32>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<i32>, <Vec<i32> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<i64>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<i64>, <Vec<i64> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<i8>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<i8>, <Vec<i8> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<u16>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<u16>, <Vec<u16> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<u32>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<u32>, <Vec<u32> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<u64>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<u64>, <Vec<u64> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl TryFrom<&Variant> for Vec<u8>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Variant, ) -> Result<Vec<u8>, <Vec<u8> as TryFrom<&Variant>>::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Variant

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,