pub struct ExtensionObject {
pub body: Option<Box<dyn DynEncodable>>,
}Expand description
An extension object holds an OPC-UA structure deserialize to a DynEncodable. This makes it possible to deserialize an extension object, the serialize it back in a different format, without reflecting over or inspecting the inner type.
Note that in order for a type to be deserialized into an ExtensionObject, the crate::Context given during deserialization needs to contain a crate::TypeLoader that can handle the type.
Fields§
§body: Option<Box<dyn DynEncodable>>The raw extension object body.
Implementations§
Source§impl ExtensionObject
impl ExtensionObject
Sourcepub fn new<T>(encodable: T) -> ExtensionObjectwhere
T: DynEncodable,
pub fn new<T>(encodable: T) -> ExtensionObjectwhere
T: DynEncodable,
Create an extension object from a structure.
Sourcepub fn null() -> ExtensionObject
pub fn null() -> ExtensionObject
Creates a null extension object, i.e. one with no value or payload
Sourcepub fn binary_type_id(&self) -> ExpandedNodeId
pub fn binary_type_id(&self) -> ExpandedNodeId
Get the binary type ID of the inner type.
Sourcepub fn object_id(&self) -> Result<ObjectId, ExtensionObjectError>
pub fn object_id(&self) -> Result<ObjectId, ExtensionObjectError>
Returns the object id of the thing this extension object contains, assuming the object id can be recognised from the node id.
Sourcepub fn from_message<T>(encodable: T) -> ExtensionObjectwhere
T: DynEncodable,
pub fn from_message<T>(encodable: T) -> ExtensionObjectwhere
T: DynEncodable,
Create an extension object from a structure.
Sourcepub fn into_inner_as<T: Send + Sync + 'static>(self) -> Option<Box<T>>
pub fn into_inner_as<T: Send + Sync + 'static>(self) -> Option<Box<T>>
Consume the extension object and return the inner value downcast to T,
if the inner type is present and is an instance of T.
You can use match_extension_object_owned for conveniently casting to one or more expected types.
Sourcepub fn inner_as<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn inner_as<T: Send + Sync + 'static>(&self) -> Option<&T>
Return the inner value by reference downcast to T,
if the inner type is present and is an instance of T.
You can use match_extension_object for conveniently casting to one or more expected types.
Sourcepub fn type_id(&self) -> Option<TypeId>
pub fn type_id(&self) -> Option<TypeId>
Get the rust std::any::TypeId of the inner type, if the extension object is not null.
Sourcepub fn type_name(&self) -> Option<&'static str>
pub fn type_name(&self) -> Option<&'static str>
Get the name of the Rust type stored in the extension object, unless it is empty.
Sourcepub fn data_type(&self) -> Option<ExpandedNodeId>
pub fn data_type(&self) -> Option<ExpandedNodeId>
Get the full data type ID of the inner type.
Note that for custom types this will not be resolved, so you need
to call ExpandedNodeId::try_resolve to get the actual NodeId.
Trait Implementations§
Source§impl BinaryDecodable for ExtensionObject
impl BinaryDecodable for ExtensionObject
Source§fn decode<S: Read + ?Sized>(
stream: &mut S,
ctx: &Context<'_>,
) -> EncodingResult<Self>
fn decode<S: Read + ?Sized>( stream: &mut S, ctx: &Context<'_>, ) -> EncodingResult<Self>
BadDecodingError as soon as possible.Source§impl BinaryEncodable for ExtensionObject
impl BinaryEncodable for ExtensionObject
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.