pub struct DynamicStructure { /* private fields */ }Expand description
A type representing an OPC-UA structure decoded dynamically. This can use runtime information to properly encode and decode binary information. In order to make the type encodable, it contains references to a StructTypeInfo describing the type it contains, as well as the DataTypeTree containing any types it references.
This type can be used to reason about data on a server without explicitly defining the server types in code, which is useful if you want to create a generic client that can work with data from any server.
Internally it is simply an array of Variant.
Note that this type is intended to support all encoding/decoding types in the OPC-UA standard, which is more than what the encoding macros currently do. This includes structurs with optional fields, unions, and multi-dimensional arrays, none of which are used in the core types.
Implementations§
Source§impl DynamicStructure
impl DynamicStructure
Sourcepub fn new_struct(
type_def: Arc<StructTypeInfo>,
type_tree: Arc<DataTypeTree>,
data: Vec<Variant>,
) -> Result<Self, Error>
pub fn new_struct( type_def: Arc<StructTypeInfo>, type_tree: Arc<DataTypeTree>, data: Vec<Variant>, ) -> Result<Self, Error>
Create a new struct, validating that it matches the provided type definition.
Sourcepub fn new_union(
type_def: Arc<StructTypeInfo>,
type_tree: Arc<DataTypeTree>,
data: Variant,
discriminant: u32,
) -> Result<Self, Error>
pub fn new_union( type_def: Arc<StructTypeInfo>, type_tree: Arc<DataTypeTree>, data: Variant, discriminant: u32, ) -> Result<Self, Error>
Create a new union, validating that it matches the provided type definition.
Sourcepub fn new_null_union(
type_def: Arc<StructTypeInfo>,
type_tree: Arc<DataTypeTree>,
) -> Self
pub fn new_null_union( type_def: Arc<StructTypeInfo>, type_tree: Arc<DataTypeTree>, ) -> Self
Create a new union, with value null.
Sourcepub fn get_field(&self, index: usize) -> Option<&Variant>
pub fn get_field(&self, index: usize) -> Option<&Variant>
Get a reference to the field at index
Sourcepub fn get_field_by_name(&self, name: &str) -> Option<&Variant>
pub fn get_field_by_name(&self, name: &str) -> Option<&Variant>
Get a reference to the field with the given name.
Trait Implementations§
Source§impl BinaryEncodable for DynamicStructure
impl BinaryEncodable for DynamicStructure
Source§fn byte_len(&self, ctx: &Context<'_>) -> usize
fn byte_len(&self, ctx: &Context<'_>) -> usize
encode were called.
This may be called prior to writing to ensure the correct amount of space is available.Source§fn encode<S: Write + ?Sized>(
&self,
stream: &mut S,
ctx: &Context<'_>,
) -> EncodingResult<()>
fn encode<S: Write + ?Sized>( &self, stream: &mut S, ctx: &Context<'_>, ) -> EncodingResult<()>
Source§fn override_encoding(&self) -> Option<BuiltInDataEncoding>
fn override_encoding(&self) -> Option<BuiltInDataEncoding>
Source§impl Clone for DynamicStructure
impl Clone for DynamicStructure
Source§fn clone(&self) -> DynamicStructure
fn clone(&self) -> DynamicStructure
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DynamicStructure
impl Debug for DynamicStructure
Source§impl ExpandedMessageInfo for DynamicStructure
impl ExpandedMessageInfo for DynamicStructure
Source§fn full_json_type_id(&self) -> ExpandedNodeId
fn full_json_type_id(&self) -> ExpandedNodeId
Source§fn full_type_id(&self) -> ExpandedNodeId
fn full_type_id(&self) -> ExpandedNodeId
Source§fn full_xml_type_id(&self) -> ExpandedNodeId
fn full_xml_type_id(&self) -> ExpandedNodeId
Source§fn full_data_type_id(&self) -> ExpandedNodeId
fn full_data_type_id(&self) -> ExpandedNodeId
Source§impl JsonEncodable for DynamicStructure
impl JsonEncodable for DynamicStructure
Source§fn encode(
&self,
stream: &mut JsonStreamWriter<&mut dyn Write>,
ctx: &Context<'_>,
) -> EncodingResult<()>
fn encode( &self, stream: &mut JsonStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> EncodingResult<()>
Source§impl PartialEq for DynamicStructure
impl PartialEq for DynamicStructure
Source§impl UaNullable for DynamicStructure
impl UaNullable for DynamicStructure
Source§fn is_ua_null(&self) -> bool
fn is_ua_null(&self) -> bool
Source§impl XmlEncodable for DynamicStructure
impl XmlEncodable for DynamicStructure
Source§fn encode(
&self,
stream: &mut XmlStreamWriter<&mut dyn Write>,
ctx: &Context<'_>,
) -> EncodingResult<()>
fn encode( &self, stream: &mut XmlStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> EncodingResult<()>
Auto Trait Implementations§
impl Freeze for DynamicStructure
impl !RefUnwindSafe for DynamicStructure
impl Send for DynamicStructure
impl Sync for DynamicStructure
impl Unpin for DynamicStructure
impl !UnwindSafe for DynamicStructure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynEncodable for Twhere
T: BinaryEncodable + JsonEncodable + XmlEncodable + ExpandedMessageInfo + Any + Debug + Send + Sync + Clone + PartialEq,
impl<T> DynEncodable for Twhere
T: BinaryEncodable + JsonEncodable + XmlEncodable + ExpandedMessageInfo + Any + Debug + Send + Sync + Clone + PartialEq,
Source§fn encode_binary(
&self,
stream: &mut dyn Write,
ctx: &Context<'_>,
) -> Result<(), Error>
fn encode_binary( &self, stream: &mut dyn Write, ctx: &Context<'_>, ) -> Result<(), Error>
Source§fn encode_json(
&self,
stream: &mut JsonStreamWriter<&mut dyn Write>,
ctx: &Context<'_>,
) -> Result<(), Error>
fn encode_json( &self, stream: &mut JsonStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> Result<(), Error>
Source§fn encode_xml(
&self,
stream: &mut XmlStreamWriter<&mut dyn Write>,
ctx: &Context<'_>,
) -> Result<(), Error>
fn encode_xml( &self, stream: &mut XmlStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> Result<(), Error>
Source§fn xml_tag_name(&self) -> &str
fn xml_tag_name(&self) -> &str
Source§fn byte_len_dyn(&self, ctx: &Context<'_>) -> usize
fn byte_len_dyn(&self, ctx: &Context<'_>) -> usize
Source§fn binary_type_id(&self) -> ExpandedNodeId
fn binary_type_id(&self) -> ExpandedNodeId
Source§fn json_type_id(&self) -> ExpandedNodeId
fn json_type_id(&self) -> ExpandedNodeId
Source§fn xml_type_id(&self) -> ExpandedNodeId
fn xml_type_id(&self) -> ExpandedNodeId
Source§fn data_type_id(&self) -> ExpandedNodeId
fn data_type_id(&self) -> ExpandedNodeId
Source§fn as_dyn_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
fn as_dyn_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
Source§fn as_dyn_any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
fn as_dyn_any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
Source§fn clone_box(&self) -> Box<dyn DynEncodable>
fn clone_box(&self) -> Box<dyn DynEncodable>
Source§fn dyn_eq(&self, other: &(dyn DynEncodable + 'static)) -> bool
fn dyn_eq(&self, other: &(dyn DynEncodable + 'static)) -> bool
Self.Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
std::any::type_name on Self.
Very useful for debugging.