Enum opcua_types::variant::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(XmlElement),
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(XmlElement)
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
sourceimpl 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<Self, StatusCode>
pub fn to_byte_array(&self) -> Result<Self, 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
sourceimpl BinaryEncoder<Variant> for Variant
impl BinaryEncoder<Variant> for Variant
sourcefn byte_len(&self) -> usize
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. Read more
sourcefn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize>
fn encode<S: Write>(&self, stream: &mut S) -> EncodingResult<usize>
Encodes the instance to the write stream.
sourcefn decode<S: Read>(
stream: &mut S,
decoding_options: &DecodingOptions
) -> EncodingResult<Self>
fn decode<S: Read>(
stream: &mut S,
decoding_options: &DecodingOptions
) -> EncodingResult<Self>
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. Read more
fn encode_to_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourceimpl<'de> Deserialize<'de> for Variant
impl<'de> Deserialize<'de> for Variant
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for Variant
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.
sourceimpl From<ByteString> for Variant
impl From<ByteString> for Variant
sourcefn from(v: ByteString) -> Self
fn from(v: ByteString) -> Self
Converts to this type from the input type.
sourceimpl From<DiagnosticInfo> for Variant
impl From<DiagnosticInfo> for Variant
sourcefn from(v: DiagnosticInfo) -> Self
fn from(v: DiagnosticInfo) -> Self
Converts to this type from the input type.
sourceimpl From<ExpandedNodeId> for Variant
impl From<ExpandedNodeId> for Variant
sourcefn from(v: ExpandedNodeId) -> Self
fn from(v: ExpandedNodeId) -> Self
Converts to this type from the input type.
sourceimpl From<ExtensionObject> for Variant
impl From<ExtensionObject> for Variant
sourcefn from(v: ExtensionObject) -> Self
fn from(v: ExtensionObject) -> Self
Converts to this type from the input type.
sourceimpl From<LocalizedText> for Variant
impl From<LocalizedText> for Variant
sourcefn from(v: LocalizedText) -> Self
fn from(v: LocalizedText) -> Self
Converts to this type from the input type.
sourceimpl From<QualifiedName> for Variant
impl From<QualifiedName> for Variant
sourcefn from(v: QualifiedName) -> Self
fn from(v: QualifiedName) -> Self
Converts to this type from the input type.
sourceimpl From<StatusCode> for Variant
impl From<StatusCode> for Variant
sourcefn from(v: StatusCode) -> Self
fn from(v: StatusCode) -> Self
Converts to this type from the input type.
sourceimpl From<Variant> for LiteralOperand
impl From<Variant> for LiteralOperand
impl StructuralPartialEq for Variant
Auto Trait Implementations
impl RefUnwindSafe for Variant
impl Send for Variant
impl Sync for Variant
impl Unpin for Variant
impl UnwindSafe for Variant
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more