Skip to main content

Variable

Struct Variable 

Source
pub struct Variable { /* private fields */ }
Expand description

A Variable is a type of node within the AddressSpace.

Implementations§

Source§

impl Variable

Source

pub fn new( node_id: &NodeId, browse_name: impl Into<QualifiedName>, display_name: impl Into<LocalizedText>, value: impl Into<Variant>, ) -> Variable

Creates a new variable. Note that data type, value rank and historizing are mandatory attributes of the Variable but not required by the constructor. The data type and value rank are inferred from the value. Historizing is not supported so is always false. If the inferred types for data type or value rank are wrong, they may be explicitly set, or call new_data_value() instead.

Source

pub fn new_full( base: Base, data_type: NodeId, historizing: bool, value_rank: i32, value: DataValue, access_level: u8, user_access_level: u8, array_dimensions: Option<Vec<u32>>, minimum_sampling_interval: Option<f64>, ) -> Self

Create a new variable with all attributes, may change if new attributes are added to the OPC-UA standard.

Note: This uses the given value and data type directly, you must ensure that the type of the value matches the data type.

Source

pub fn from_attributes( node_id: &NodeId, browse_name: impl Into<QualifiedName>, attributes: VariableAttributes, ) -> Result<Self, FromAttributesError>

Create a new variable from VariableAttributes.

Source

pub fn new_data_value<S, R, N, V>( node_id: &NodeId, browse_name: R, display_name: S, data_type: N, value_rank: Option<i32>, array_dimensions: Option<u32>, value: V, ) -> Variable

Constructs a new variable with the specified id, name, type and value

Source

pub fn is_valid(&self) -> bool

Get whether this is a valid instance of a variable.

Source

pub fn value( &self, timestamps_to_return: TimestampsToReturn, index_range: &NumericRange, _data_encoding: &DataEncoding, _max_age: f64, ) -> DataValue

Read the value of the variable.

Source

pub fn set_value<V>( &mut self, index_range: &NumericRange, value: V, ) -> Result<(), StatusCode>
where V: Into<Variant>,

Sets the variable’s Variant value. The timestamps for the change are updated to now.

Source

pub fn set_value_range( &mut self, value: Variant, index_range: &NumericRange, status_code: StatusCode, server_timestamp: &DateTime, source_timestamp: &DateTime, ) -> Result<(), StatusCode>

Set a part of the current value given by index_range.

Source

pub fn set_value_direct<V>( &mut self, value: V, status_code: StatusCode, server_timestamp: &DateTime, source_timestamp: &DateTime, ) -> Result<(), StatusCode>
where V: Into<Variant>,

Sets the variable’s DataValue

Source

pub fn set_data_value(&mut self, value: DataValue)

Sets the variable type’s DataValue

Source

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

Gets the minimum sampling interval, if the attribute was set

Source

pub fn set_minimum_sampling_interval(&mut self, minimum_sampling_interval: f64)

Sets the minimum sampling interval

Specifies in milliseconds how fast the server can reasonably sample the value for changes

The value 0 means server is to monitor the value continuously. The value -1 means indeterminate.

Source

pub fn is_readable(&self) -> bool

Test if the variable is readable. This will be called by services before getting the value of the node.

Source

pub fn is_writable(&self) -> bool

Test if the variable is writable. This will be called by services before setting the value on the node.

Source

pub fn set_writable(&mut self, writable: bool)

Sets the variable writable state.

Source

pub fn access_level(&self) -> AccessLevel

Returns the access level of the variable.

Source

pub fn set_access_level(&mut self, access_level: AccessLevel)

Sets the access level of the variable.

Source

pub fn is_user_readable(&self) -> bool

Test if the variable is user readable.

Source

pub fn is_user_writable(&self) -> bool

Test if the variable is user writable.

Source

pub fn user_access_level(&self) -> AccessLevel

Returns the user access level of the variable.

Source

pub fn set_user_access_level(&mut self, user_access_level: AccessLevel)

Set the user access level of the variable.

Source

pub fn value_rank(&self) -> i32

Get the variable value rank.

Source

pub fn set_value_rank(&mut self, value_rank: i32)

Set the variable value rank.

Source

pub fn historizing(&self) -> bool

Get the Historizing attribute of the variable, whether it stores new values in a historical store.

Source

pub fn set_historizing(&mut self, historizing: bool)

Set the Historizing attribute of the variable, whether it stores new values in a historical store.

Source

pub fn array_dimensions(&self) -> Option<Vec<u32>>

Get the array dimensions of this variable.

Source

pub fn set_array_dimensions(&mut self, array_dimensions: &[u32])

Set the array dimensions of this variable.

Source

pub fn data_type(&self) -> NodeId

Get the data type of this variable.

Source

pub fn set_data_type(&mut self, data_type: impl Into<NodeId>)

Set the data type of this variable.

Trait Implementations§

Source§

impl Debug for Variable

Source§

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

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

impl Default for Variable

Source§

fn default() -> Self

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

impl From<Variable> for NodeType

Source§

fn from(value: Variable) -> Self

Converts to this type from the input type.
Source§

impl Node for Variable

Source§

fn get_attribute_max_age( &self, timestamps_to_return: TimestampsToReturn, attribute_id: AttributeId, index_range: &NumericRange, data_encoding: &DataEncoding, max_age: f64, ) -> Option<DataValue>

Finds the attribute and value. The param max_age is a hint in milliseconds: Read more
Source§

fn set_attribute( &mut self, attribute_id: AttributeId, value: Variant, ) -> Result<(), StatusCode>

Sets the attribute with the new value
Source§

fn get_attribute( &self, timestamps_to_return: TimestampsToReturn, attribute_id: AttributeId, index_range: &NumericRange, data_encoding: &DataEncoding, ) -> Option<DataValue>

Finds the attribute and value.
Source§

impl NodeBase for Variable

Source§

fn node_class(&self) -> NodeClass

Returns the node class - Object, ObjectType, Method, DataType, ReferenceType, Variable, VariableType or View
Source§

fn node_id(&self) -> &NodeId

Returns the node’s NodeId
Source§

fn browse_name(&self) -> &QualifiedName

Returns the node’s browse name
Source§

fn display_name(&self) -> &LocalizedText

Returns the node’s display name
Source§

fn set_display_name(&mut self, display_name: LocalizedText)

Sets the node’s display name
Source§

fn description(&self) -> Option<&LocalizedText>

Get the description of this node.
Source§

fn set_description(&mut self, description: LocalizedText)

Set the description of this node.
Source§

fn write_mask(&self) -> Option<WriteMask>

Get the write mask of this node.
Source§

fn set_write_mask(&mut self, write_mask: WriteMask)

Set the write mask of this node.
Source§

fn user_write_mask(&self) -> Option<WriteMask>

Get the user write mask for this node.
Source§

fn set_user_write_mask(&mut self, user_write_mask: WriteMask)

Set the user write mask for this node.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more