Skip to main content

Variant

Struct Variant 

Source
pub struct Variant(/* private fields */);
Expand description

Wrapper for UA_Variant from open62541_sys.

This owns the wrapped data. When the wrapper is dropped, the inner value is cleaned up with UA_clear() to release dynamically allocated memory held by the value.

Implementations§

Source§

impl Variant

Source

pub fn scalar<T: DataType>(value: T) -> Self

Creates variant from scalar.

Source

pub fn array<T: DataType>(value: Array<T>) -> Self

Creates variant from array.

Source

pub fn with_scalar<T: DataType>(self, value: &T) -> Self

Source

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

Gets data type’s node ID.

Returns None when the variant is empty.

Source

pub fn value_type(&self) -> Option<ValueType>

Gets value type.

Returns None when the variant is empty.

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_scalar(&self) -> bool

Source

pub fn as_scalar<T>(&self) -> Option<&T>
where T: DataType,

Source

pub fn to_scalar<T>(&self) -> Option<T>
where T: DataType,

Source

pub fn into_scalar<T>(self) -> Option<T>
where T: DataType,

Source

pub fn to_array<T: DataType>(&self) -> Option<Array<T>>

Source

pub fn to_value(&self) -> VariantValue

Source

pub fn json(&self) -> Option<Value>

Trait Implementations§

Source§

impl Clone for Variant

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl DataType for Variant

Source§

type Inner = UA_Variant

Inner type. Read more
Source§

fn data_type() -> *const UA_DataType

Gets open62541 data type record. Read more
Source§

unsafe fn from_raw(src: Self::Inner) -> Self

Creates wrapper by taking ownership of value. Read more
Source§

fn into_raw(self) -> Self::Inner

Gives up ownership and returns value. Read more
Source§

fn type_name() -> &'static str

Gets data type name.
Source§

fn init() -> Self

Creates wrapper initialized with defaults. Read more
Source§

fn raw_ref(src: &Self::Inner) -> &Self

Creates wrapper reference from value.
Source§

fn raw_mut(src: &mut Self::Inner) -> &mut Self

Creates mutable wrapper reference from value.
Source§

fn clone_raw(src: &Self::Inner) -> Self

Creates wrapper by cloning value from src. Read more
Source§

fn take_raw(src: &mut Self::Inner) -> Self

Creates wrapper by moving value from src. Read more
Source§

fn clone_into_raw(&self, dst: &mut Self::Inner)

Clones value into dst. Read more
Source§

fn move_into_raw(self, dst: &mut Self::Inner)

Moves value into dst, giving up ownership. Read more
Source§

fn leak_into_raw(self) -> *mut Self::Inner

Leaks wrapped value onto the heap. Read more
Source§

unsafe fn to_raw_copy(this: &Self) -> Self::Inner

Creates copy without giving up ownership. Read more
Source§

unsafe fn as_ref(&self) -> &Self::Inner

Returns shared reference to value. Read more
Source§

unsafe fn as_mut(&mut self) -> &mut Self::Inner

Returns exclusive reference to value. Read more
Source§

unsafe fn as_ptr(&self) -> *const Self::Inner

Returns const pointer to value. Read more
Source§

unsafe fn as_mut_ptr(&mut self) -> *mut Self::Inner

Returns mutable pointer to value. Read more
Source§

fn print(this: &Self) -> Option<String>

Prints value to string. Read more
Source§

fn order(this: &Self, other: &Self) -> UA_Order

Compares value to other. Read more
Source§

impl Debug for Variant

Source§

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

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

impl Drop for Variant

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Variant

Source§

impl Ord for Variant

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Variant

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Variant

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Send for Variant

Source§

impl Serialize for Variant

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

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

impl Sync 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> DataTypeExt for T
where T: DataType,

Source§

type Inner = T

Inner type sent over the wire.
Source§

fn from_inner(value: <T as DataTypeExt>::Inner) -> Result<T, Error>

Creates instance for inner type. Read more
Source§

fn into_inner(self) -> <T as DataTypeExt>::Inner

Returns inner type representation.
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, 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.