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§
Sourcefn encode_binary(
&self,
stream: &mut dyn Write,
ctx: &Context<'_>,
) -> Result<(), Error>
fn encode_binary( &self, stream: &mut dyn Write, ctx: &Context<'_>, ) -> Result<(), Error>
Encode the struct using OPC-UA binary encoding.
Sourcefn 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>
Encode the struct using reversible OPC-UA JSON encoding.
Sourcefn 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>
Encode the struct using OPC-UA XML encoding.
Sourcefn xml_tag_name(&self) -> &str
fn xml_tag_name(&self) -> &str
The XML tag name for this struct.
Sourcefn byte_len_dyn(&self, ctx: &Context<'_>) -> usize
fn byte_len_dyn(&self, ctx: &Context<'_>) -> usize
Get the binary byte length of this struct.
Sourcefn binary_type_id(&self) -> ExpandedNodeId
fn binary_type_id(&self) -> ExpandedNodeId
Get the binary encoding ID of this struct.
Sourcefn json_type_id(&self) -> ExpandedNodeId
fn json_type_id(&self) -> ExpandedNodeId
Get the JSON encoding ID of this struct.
Sourcefn xml_type_id(&self) -> ExpandedNodeId
fn xml_type_id(&self) -> ExpandedNodeId
Get the XML encoding ID of this struct.
Sourcefn data_type_id(&self) -> ExpandedNodeId
fn data_type_id(&self) -> ExpandedNodeId
Get the data type ID of this struct.
Sourcefn as_dyn_any(self: Box<Self>) -> Box<dyn Any + Sync + Send>
fn as_dyn_any(self: Box<Self>) -> Box<dyn Any + Sync + Send>
Method to cast this to a dyn Any box, required for downcasting.
Sourcefn as_dyn_any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
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.
Sourcefn clone_box(&self) -> Box<dyn DynEncodable>
fn clone_box(&self) -> Box<dyn DynEncodable>
Clone this to a dyn box. Required in order to implement Clone for ExtensionObject.
Sourcefn dyn_eq(&self, other: &(dyn DynEncodable + 'static)) -> bool
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.
Sourcefn type_name(&self) -> &'static str
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.
Sourcefn override_encoding(&self) -> Option<BuiltInDataEncoding>
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
impl PartialEq for dyn DynEncodable
Source§fn eq(&self, other: &(dyn DynEncodable + 'static)) -> bool
fn eq(&self, other: &(dyn DynEncodable + 'static)) -> bool
self and other values to be equal, and is used by ==.