Struct opcua_server::address_space::address_space::AddressSpace
source · [−]pub struct AddressSpace { /* private fields */ }
Expand description
The AddressSpace
describes all of the nodes managed by the server and the references between
them. Usually it will be populated with the default OPC UA node set plus any that have been
added by the server.
The AddressSpace
enforces minimal modelling rules - the implementation is expected to abide
by rules when adding nodes. To aid with adding nodes to the address space, each node is
a NodeType
which can be one of DataType
, Object
, ObjectType
, ReferenceType
, Method
,
Variable
, VariableType
or View
. Each node type has various mandatory and optional
attributes that can be set with function calls. In addition, each node type has a corresponding
builder, e.g. VariableBuilder
that can be used to simplify adding nodes.
Some of the methods in AddressSpace
are liable to change over time especially as more of the
heavy lifting is done via builders.
Implementations
sourceimpl AddressSpace
impl AddressSpace
sourcepub fn new() -> AddressSpace
pub fn new() -> AddressSpace
Constructs a default address space consisting of all the nodes and references in the OPC UA default nodeset.
sourcepub fn last_modified(&self) -> DateTimeUtc
pub fn last_modified(&self) -> DateTimeUtc
Returns the last modified date for the address space
sourcepub fn register_namespace(&mut self, namespace: &str) -> Result<u16, ()>
pub fn register_namespace(&mut self, namespace: &str) -> Result<u16, ()>
Registers a namespace described by a uri with address space. The return code is the index
of the newly added namespace / index. The index is used with NodeId
. Registering a
namespace that is already registered will return the index to the previous instance.
The last registered namespace becomes the default namespace unless you explcitly call
set_default_namespace()
after this.
sourcepub fn namespace_index(&self, namespace: &str) -> Option<u16>
pub fn namespace_index(&self, namespace: &str) -> Option<u16>
Finds the namespace index of a given namespace
sourcepub fn set_service_level(&mut self, service_level: u8, now: &DateTime)
pub fn set_service_level(&mut self, service_level: u8, now: &DateTime)
Sets the service level 0-255 worst to best quality of service
sourcepub fn set_server_state(&mut self, server_state: Arc<RwLock<ServerState>>)
pub fn set_server_state(&mut self, server_state: Arc<RwLock<ServerState>>)
Sets values for nodes representing the server.
sourcepub fn set_history_server_capabilities(
&mut self,
capabilities: &HistoryServerCapabilities
)
pub fn set_history_server_capabilities(
&mut self,
capabilities: &HistoryServerCapabilities
)
Sets the history server capabilities based on the supplied flags
sourcepub fn root_folder(&self) -> &Object
pub fn root_folder(&self) -> &Object
Returns the root folder
sourcepub fn objects_folder(&self) -> &Object
pub fn objects_folder(&self) -> &Object
Returns the objects folder
sourcepub fn types_folder(&self) -> &Object
pub fn types_folder(&self) -> &Object
Returns the types folder
sourcepub fn views_folder(&self) -> &Object
pub fn views_folder(&self) -> &Object
Returns the views folder
sourcepub fn set_default_namespace(&mut self, default_namespace: u16)
pub fn set_default_namespace(&mut self, default_namespace: u16)
Sets the default namespace
sourcepub fn default_namespace(&self) -> u16
pub fn default_namespace(&self) -> u16
Gets the default namespace
sourcepub fn audit_namespace(&self) -> u16
pub fn audit_namespace(&self) -> u16
Get the default namespace for audit events
sourcepub fn internal_namespace(&self) -> u16
pub fn internal_namespace(&self) -> u16
Get the internal namespace
sourcepub fn insert<T, S>(
&mut self,
node: T,
references: Option<&[(&NodeId, &S, ReferenceDirection)]>
) -> bool where
T: Into<NodeType>,
S: Into<NodeId> + Clone,
pub fn insert<T, S>(
&mut self,
node: T,
references: Option<&[(&NodeId, &S, ReferenceDirection)]>
) -> bool where
T: Into<NodeType>,
S: Into<NodeId> + Clone,
Inserts a node into the address space node map and its references to other target nodes. The tuple of references is the target node id, reference type id and a bool which is false for a forward reference and indicating inverse
sourcepub fn add_default_nodes(&mut self)
pub fn add_default_nodes(&mut self)
Adds the standard nodeset to the address space
pub fn insert_references<T>(&mut self, references: &[(&NodeId, &NodeId, &T)]) where
T: Into<NodeId> + Clone,
sourcepub fn insert_reference<T>(
&mut self,
node_id: &NodeId,
target_node_id: &NodeId,
reference_type_id: T
) where
T: Into<NodeId> + Clone,
pub fn insert_reference<T>(
&mut self,
node_id: &NodeId,
target_node_id: &NodeId,
reference_type_id: T
) where
T: Into<NodeId> + Clone,
Inserts a single reference between two nodes in the address space
pub fn set_node_type<T>(&mut self, node_id: &NodeId, node_type: T) where
T: Into<NodeId>,
pub fn node_exists(&self, node_id: &NodeId) -> bool
sourcepub fn add_folder_with_id<R, S>(
&mut self,
node_id: &NodeId,
browse_name: R,
display_name: S,
parent_node_id: &NodeId
) -> bool where
R: Into<QualifiedName>,
S: Into<LocalizedText>,
pub fn add_folder_with_id<R, S>(
&mut self,
node_id: &NodeId,
browse_name: R,
display_name: S,
parent_node_id: &NodeId
) -> bool where
R: Into<QualifiedName>,
S: Into<LocalizedText>,
Adds a folder with a specified id
sourcepub fn add_folder<R, S>(
&mut self,
browse_name: R,
display_name: S,
parent_node_id: &NodeId
) -> Result<NodeId, ()> where
R: Into<QualifiedName>,
S: Into<LocalizedText>,
pub fn add_folder<R, S>(
&mut self,
browse_name: R,
display_name: S,
parent_node_id: &NodeId
) -> Result<NodeId, ()> where
R: Into<QualifiedName>,
S: Into<LocalizedText>,
Adds a folder using a generated node id
sourcepub fn add_variables(
&mut self,
variables: Vec<Variable>,
parent_node_id: &NodeId
) -> Vec<bool>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn add_variables(
&mut self,
variables: Vec<Variable>,
parent_node_id: &NodeId
) -> Vec<bool>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Adds a list of variables to the specified parent node
sourcepub fn delete(
&mut self,
node_id: &NodeId,
delete_target_references: bool
) -> bool
pub fn delete(
&mut self,
node_id: &NodeId,
delete_target_references: bool
) -> bool
Deletes a node by its node id, and all of its properties and optionally any references to or from it it in the address space.
sourcepub fn delete_reference<T>(
&mut self,
node_id: &NodeId,
target_node_id: &NodeId,
reference_type_id: T
) -> bool where
T: Into<NodeId>,
pub fn delete_reference<T>(
&mut self,
node_id: &NodeId,
target_node_id: &NodeId,
reference_type_id: T
) -> bool where
T: Into<NodeId>,
Finds the matching reference and deletes it
sourcepub fn find<N>(&self, node_id: N) -> Option<&NodeType> where
N: Into<NodeId>,
pub fn find<N>(&self, node_id: N) -> Option<&NodeType> where
N: Into<NodeId>,
Find node by something that can be turned into a node id and return a reference to it.
sourcepub fn find_mut<N>(&mut self, node_id: N) -> Option<&mut NodeType> where
N: Into<NodeId>,
pub fn find_mut<N>(&mut self, node_id: N) -> Option<&mut NodeType> where
N: Into<NodeId>,
Find node by something that can be turned into a node id and return a mutable reference to it.
sourcepub fn find_node(&self, node_id: &NodeId) -> Option<&NodeType>
pub fn find_node(&self, node_id: &NodeId) -> Option<&NodeType>
Finds a node by its node id and returns a reference to it.
sourcepub fn find_node_mut(&mut self, node_id: &NodeId) -> Option<&mut NodeType>
pub fn find_node_mut(&mut self, node_id: &NodeId) -> Option<&mut NodeType>
Finds a node by its node id and returns a mutable reference to it.
sourcepub fn find_variable<N>(&self, node_id: N) -> Option<&Variable> where
N: Into<NodeId>,
pub fn find_variable<N>(&self, node_id: N) -> Option<&Variable> where
N: Into<NodeId>,
Find and return a variable with the specified node id or return None if it cannot be found or is not a variable
sourcepub fn find_variable_by_ref(&self, node_id: &NodeId) -> Option<&Variable>
pub fn find_variable_by_ref(&self, node_id: &NodeId) -> Option<&Variable>
Find and return a variable with the specified node id or return None if it cannot be found or is not a variable
sourcepub fn find_variable_mut<N>(&mut self, node_id: N) -> Option<&mut Variable> where
N: Into<NodeId>,
pub fn find_variable_mut<N>(&mut self, node_id: N) -> Option<&mut Variable> where
N: Into<NodeId>,
Find and return a variable with the specified node id or return None if it cannot be found or is not a variable
sourcepub fn find_variable_mut_by_ref(
&mut self,
node_id: &NodeId
) -> Option<&mut Variable>
pub fn find_variable_mut_by_ref(
&mut self,
node_id: &NodeId
) -> Option<&mut Variable>
Find and return a variable with the specified node id or return None if it cannot be found or is not a variable
sourcepub fn set_variable_value<N, V>(
&mut self,
node_id: N,
value: V,
source_timestamp: &DateTime,
server_timestamp: &DateTime
) -> bool where
N: Into<NodeId>,
V: Into<Variant>,
pub fn set_variable_value<N, V>(
&mut self,
node_id: N,
value: V,
source_timestamp: &DateTime,
server_timestamp: &DateTime
) -> bool where
N: Into<NodeId>,
V: Into<Variant>,
Set a variable value from its NodeId. The function will return false if the variable does not exist, or the node is not a variable.
sourcepub fn set_variable_value_by_ref<V>(
&mut self,
node_id: &NodeId,
value: V,
source_timestamp: &DateTime,
server_timestamp: &DateTime
) -> bool where
V: Into<Variant>,
pub fn set_variable_value_by_ref<V>(
&mut self,
node_id: &NodeId,
value: V,
source_timestamp: &DateTime,
server_timestamp: &DateTime
) -> bool where
V: Into<Variant>,
Set a variable value from its NodeId. The function will return false if the variable does not exist, or the node is not a variable.
sourcepub fn get_variable_value<N>(&self, node_id: N) -> Result<DataValue, ()> where
N: Into<NodeId>,
pub fn get_variable_value<N>(&self, node_id: N) -> Result<DataValue, ()> where
N: Into<NodeId>,
Gets a variable value with the supplied NodeId. The function will return Err if the NodeId does not exist or is not a variable.
sourcepub fn register_method_handler<N>(
&mut self,
method_id: N,
handler: Box<dyn Method + Send + Sync>
) where
N: Into<NodeId>,
pub fn register_method_handler<N>(
&mut self,
method_id: N,
handler: Box<dyn Method + Send + Sync>
) where
N: Into<NodeId>,
Registers a method callback on the specified object id and method id
sourcepub fn is_valid_type_definition(
&self,
node_class: NodeClass,
type_definition: &NodeId
) -> bool
pub fn is_valid_type_definition(
&self,
node_class: NodeClass,
type_definition: &NodeId
) -> bool
Test if the type definition is defined and valid for a class of the specified type. i.e. if we have a Variable or Object class that the type is a VariableType or ObjectType respectively.
sourcepub fn has_reference<T>(
&self,
source_node: &NodeId,
target_node: &NodeId,
reference_type: T
) -> bool where
T: Into<NodeId>,
pub fn has_reference<T>(
&self,
source_node: &NodeId,
target_node: &NodeId,
reference_type: T
) -> bool where
T: Into<NodeId>,
Test if a reference relationship exists between one node and another node
sourcepub fn call_method(
&mut self,
_server_state: &ServerState,
session_id: &NodeId,
session_manager: Arc<RwLock<SessionManager>>,
request: &CallMethodRequest
) -> Result<CallMethodResult, StatusCode>
pub fn call_method(
&mut self,
_server_state: &ServerState,
session_id: &NodeId,
session_manager: Arc<RwLock<SessionManager>>,
request: &CallMethodRequest
) -> Result<CallMethodResult, StatusCode>
Calls a method node with the supplied request and expecting a result.
Calls require a registered handler to handle the method. If there is no handler, or if the request refers to a non existent object / method, the function will return an error.
sourcepub fn is_subtype(&self, subtype_id: &NodeId, base_type_id: &NodeId) -> bool
pub fn is_subtype(&self, subtype_id: &NodeId, base_type_id: &NodeId) -> bool
Recursive function tries to find if a type is a subtype of another type by looking at its references. Function will positively match a type against itself.
pub fn find_objects_by_type<T>(
&self,
object_type: T,
include_subtypes: bool
) -> Option<Vec<NodeId>> where
T: Into<NodeId>,
pub fn find_variables_by_type<T>(
&self,
variable_type: T,
include_subtypes: bool
) -> Option<Vec<NodeId>> where
T: Into<NodeId>,
sourcepub fn find_aggregates_of(&self, parent_node: &NodeId) -> Option<Vec<NodeId>>
pub fn find_aggregates_of(&self, parent_node: &NodeId) -> Option<Vec<NodeId>>
Finds all child propertiesof the parent node. i.e. Aggregates or any subtype
sourcepub fn find_hierarchical_references(
&self,
parent_node: &NodeId
) -> Option<Vec<NodeId>>
pub fn find_hierarchical_references(
&self,
parent_node: &NodeId
) -> Option<Vec<NodeId>>
Finds hierarchical references of the parent node, i.e. children, event sources, organizes etc from the parent node to other nodes. This function will return node ids even if the nodes themselves do not exist in the address space.
sourcepub fn find_references<T>(
&self,
node: &NodeId,
reference_filter: Option<(T, bool)>
) -> Option<Vec<Reference>> where
T: Into<NodeId> + Clone,
pub fn find_references<T>(
&self,
node: &NodeId,
reference_filter: Option<(T, bool)>
) -> Option<Vec<Reference>> where
T: Into<NodeId> + Clone,
Finds forward references from the specified node. The reference filter can optionally filter results by a specific type and subtypes.
sourcepub fn find_inverse_references<T>(
&self,
node: &NodeId,
reference_filter: Option<(T, bool)>
) -> Option<Vec<Reference>> where
T: Into<NodeId> + Clone,
pub fn find_inverse_references<T>(
&self,
node: &NodeId,
reference_filter: Option<(T, bool)>
) -> Option<Vec<Reference>> where
T: Into<NodeId> + Clone,
Finds inverse references, it those that point to the specified node. The reference filter can optionally filter results by a specific type and subtypes.
sourcepub fn find_references_by_direction<T>(
&self,
node_id: &NodeId,
browse_direction: BrowseDirection,
reference_filter: Option<(T, bool)>
) -> (Vec<Reference>, usize) where
T: Into<NodeId> + Clone,
pub fn find_references_by_direction<T>(
&self,
node_id: &NodeId,
browse_direction: BrowseDirection,
reference_filter: Option<(T, bool)>
) -> (Vec<Reference>, usize) where
T: Into<NodeId> + Clone,
Finds references for optionally forwards, inverse or both and return the references. The usize represents the index in the collection where the inverse references start (if applicable)
sourcepub fn references(&self) -> &References
pub fn references(&self) -> &References
Returns the references
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for AddressSpace
impl Send for AddressSpace
impl Sync for AddressSpace
impl Unpin for AddressSpace
impl !UnwindSafe for AddressSpace
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