Skip to main content

DynEncodable

Trait DynEncodable 

Source
pub trait DynEncodable:
    Any
    + Send
    + Sync
    + Debug {
Show 15 methods // Required methods fn encode_binary( &self, stream: &mut dyn Write, ctx: &Context<'_>, ) -> Result<(), Error>; fn encode_json( &self, stream: &mut JsonStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> Result<(), Error>; fn encode_xml( &self, stream: &mut XmlStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> Result<(), Error>; fn xml_tag_name(&self) -> &str; fn byte_len_dyn(&self, ctx: &Context<'_>) -> usize; fn binary_type_id(&self) -> ExpandedNodeId; fn json_type_id(&self) -> ExpandedNodeId; fn xml_type_id(&self) -> ExpandedNodeId; fn data_type_id(&self) -> ExpandedNodeId; fn as_dyn_any(self: Box<Self>) -> Box<dyn Any + Sync + Send>; fn as_dyn_any_ref(&self) -> &(dyn Any + Sync + Send + 'static); fn clone_box(&self) -> Box<dyn DynEncodable>; fn dyn_eq(&self, other: &(dyn DynEncodable + 'static)) -> bool; fn type_name(&self) -> &'static str; fn override_encoding(&self) -> Option<BuiltInDataEncoding>;
}
Expand description

Trait for an OPC-UA struct that can be dynamically encoded back to binary (or JSON). ExtensionObject wraps a dynamic object for this trait. Note that this trait is automatically implemented for anything that implements BinaryEncodable, JsonEncodable (with the json feature), Send, Sync, Clone, ExpandedMessageInfo, std::fmt::Debug and PartialEq.

All of these are automatically derived during codegen, if you want to manually implement a type that can be stored as an extension object, you need to implement or derive all of these traits.

Required Methods§

Source

fn encode_binary( &self, stream: &mut dyn Write, ctx: &Context<'_>, ) -> Result<(), Error>

Encode the struct using OPC-UA binary encoding.

Source

fn encode_json( &self, stream: &mut JsonStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> Result<(), Error>

Encode the struct using reversible OPC-UA JSON encoding.

Source

fn encode_xml( &self, stream: &mut XmlStreamWriter<&mut dyn Write>, ctx: &Context<'_>, ) -> Result<(), Error>

Encode the struct using OPC-UA XML encoding.

Source

fn xml_tag_name(&self) -> &str

The XML tag name for this struct.

Source

fn byte_len_dyn(&self, ctx: &Context<'_>) -> usize

Get the binary byte length of this struct.

Source

fn binary_type_id(&self) -> ExpandedNodeId

Get the binary encoding ID of this struct.

Source

fn json_type_id(&self) -> ExpandedNodeId

Get the JSON encoding ID of this struct.

Source

fn xml_type_id(&self) -> ExpandedNodeId

Get the XML encoding ID of this struct.

Source

fn data_type_id(&self) -> ExpandedNodeId

Get the data type ID of this struct.

Source

fn as_dyn_any(self: Box<Self>) -> Box<dyn Any + Sync + Send>

Method to cast this to a dyn Any box, required for downcasting.

Source

fn as_dyn_any_ref(&self) -> &(dyn Any + Sync + Send + 'static)

Method to cast this to a dyn Any trait object, required for downcasting by reference.

Source

fn clone_box(&self) -> Box<dyn DynEncodable>

Clone this to a dyn box. Required in order to implement Clone for ExtensionObject.

Source

fn dyn_eq(&self, other: &(dyn DynEncodable + 'static)) -> bool

Compare this with dynamic object. Invokes the PartialEq implementation of self and other, if other has type Self.

Source

fn type_name(&self) -> &'static str

Get the type name of the type, by calling std::any::type_name on Self. Very useful for debugging.

Source

fn override_encoding(&self) -> Option<BuiltInDataEncoding>

Override the extension object encoding used for this type. This only makes sense if the type can only ever be encoded using a single built-in encoding.

Trait Implementations§

Source§

impl PartialEq for dyn DynEncodable

Source§

fn eq(&self, other: &(dyn DynEncodable + 'static)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementors§