Trait DataType

Source
pub unsafe trait DataType: Debug + Clone {
    type Inner;

Show 18 methods // Required methods fn data_type() -> *const UA_DataType; unsafe fn from_raw(src: Self::Inner) -> Self; fn into_raw(self) -> Self::Inner; // Provided methods fn type_name() -> &'static str { ... } fn init() -> Self { ... } fn raw_ref(src: &Self::Inner) -> &Self { ... } fn raw_mut(src: &mut Self::Inner) -> &mut Self { ... } fn clone_raw(src: &Self::Inner) -> Self { ... } fn clone_into_raw(&self, dst: &mut Self::Inner) { ... } fn move_into_raw(self, dst: &mut Self::Inner) { ... } fn leak_into_raw(self) -> *mut Self::Inner { ... } unsafe fn to_raw_copy(this: &Self) -> Self::Inner { ... } unsafe fn as_ref(&self) -> &Self::Inner { ... } unsafe fn as_mut(&mut self) -> &mut Self::Inner { ... } unsafe fn as_ptr(&self) -> *const Self::Inner { ... } unsafe fn as_mut_ptr(&mut self) -> *mut Self::Inner { ... } fn print(this: &Self) -> Option<String> { ... } fn order(this: &Self, other: &Self) -> UA_Order { ... }
}
Expand description

Transparent wrapper for OPC UA data type.

§Safety

It must be possible to transmute between the type that implements DataType and the inner type Inner. This implies that #[repr(transparent)] must be used on types that implement this trait and the inner type must be Inner.

In addition, the inner type must not contain self-references (in Rust terms, it would have to implement the Unpin trait). This is usually the case for types from open62541_sys, as they are regularly passed by value to functions in order to transfer ownership.

Required Associated Types§

Source

type Inner

Inner type.

It must be possible to transmute between the inner type and the type that implements DataType.

Required Methods§

Source

fn data_type() -> *const UA_DataType

Gets open62541 data type record.

The result can be passed to functions in open62541 that deal with arbitrary data types.

Source

unsafe fn from_raw(src: Self::Inner) -> Self

Creates wrapper by taking ownership of value.

When Self is dropped, UA_clear() is used to free allocations held by the inner type. Move only values into Self that can be cleared in-place such as stack-allocated values (but no heap-allocated values created by UA_new()).

§Safety

Ownership of the value passes to Self. This must only be used for values that are not contained within other values that may be dropped (such as attributes in other data types). In this case use clone_raw() instead to clone data instead of taking ownership.

Source

fn into_raw(self) -> Self::Inner

Gives up ownership and returns value.

The returned value must be re-wrapped with from_raw() or cleared manually with UA_clear() to free internal allocations and not leak memory.

Provided Methods§

Source

fn type_name() -> &'static str

Gets data type name.

Source

fn init() -> Self

Creates wrapper initialized with defaults.

This uses UA_init() to initialize the value and make all attributes well-defined. Depending on the type, additional attributes may need to be initialized for the value to be actually useful afterwards.

Source

fn raw_ref(src: &Self::Inner) -> &Self

Creates wrapper reference from value.

Source

fn raw_mut(src: &mut Self::Inner) -> &mut Self

Creates mutable wrapper reference from value.

Source

fn clone_raw(src: &Self::Inner) -> Self

Creates wrapper by cloning value from src.

This uses UA_copy() to deeply copy an existing value without transferring ownership.

The original value must be cleared with UA_clear(), or deleted with UA_delete() if allocated on the heap, to avoid memory leaks. If src is borrowed from another data type wrapper, that wrapper will make sure of this.

Source

fn clone_into_raw(&self, dst: &mut Self::Inner)

Clones value into dst.

This uses UA_copy() to deeply copy an existing value without transferring ownership.

Existing data in dst is cleared with UA_clear() before cloning the value; it is safe to use this operation on already initialized target values.

Source

fn move_into_raw(self, dst: &mut Self::Inner)

Moves value into dst, giving up ownership.

Existing data in dst is cleared with UA_clear() before moving the value; it is safe to use this operation on already initialized target values.

After this, it is the responsibility of dst to eventually clean up the data.

Source

fn leak_into_raw(self) -> *mut Self::Inner

Leaks wrapped value onto the heap.

This turns a stack-allocated value into a heap-allocated one, without issuing a deep copy. In other words, only the local memory allocation is copied (moved from stack to heap) and any memory that is already heap-allocated (e.g. string contents) stays where it is.

The returned value must be passed into another owned data structure or freed manually with UA_delete() to free internal allocations and not leak memory.

Source

unsafe fn to_raw_copy(this: &Self) -> Self::Inner

Creates copy without giving up ownership.

§Safety

Think twice before using this. Pointers to dynamically allocated attributes within Self are copied and will become dangling pointers when self is dropped.

This function is necessary because some functions in open62541 take arguments by value instead of by pointer without taking ownership and make the caller responsible for cleaning up after the call has returned.

Source

unsafe fn as_ref(&self) -> &Self::Inner

Returns shared reference to value.

§Safety

The value is owned by Self. Ownership must not be given away, in whole or in parts. This may happen when open62541 functions are called that take ownership of values by pointer.

Source

unsafe fn as_mut(&mut self) -> &mut Self::Inner

Returns exclusive reference to value.

§Safety

The value is owned by Self. Ownership must not be given away, in whole or in parts. This may happen when open62541 functions are called that take ownership of values by pointer.

Source

unsafe fn as_ptr(&self) -> *const Self::Inner

Returns const pointer to value.

§Safety

The value is owned by Self. Ownership must not be given away, in whole or in parts. This may happen when open62541 functions are called that take ownership of values by pointer.

Source

unsafe fn as_mut_ptr(&mut self) -> *mut Self::Inner

Returns mutable pointer to value.

§Safety

The value is owned by Self. Ownership must not be given away, in whole or in parts. This may happen when open62541 functions are called that take ownership of values by pointer.

Source

fn print(this: &Self) -> Option<String>

Prints value to string.

This uses UA_print() to generate the string representation.

§Note

The string representation is not guaranteed to be stable across versions.

Source

fn order(this: &Self, other: &Self) -> UA_Order

Compares value to other.

This uses UA_order() to derive a total ordering between values.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl DataType for AggregateFilter

Source§

impl DataType for AnonymousIdentityToken

Source§

impl DataType for ApplicationDescription

Source§

impl DataType for ApplicationType

Source§

impl DataType for Argument

Source§

impl DataType for AttributeId

Source§

impl DataType for AttributeOperand

Source§

impl DataType for Boolean

Source§

impl DataType for BrowseDescription

Source§

impl DataType for BrowseDirection

Source§

impl DataType for BrowseNextRequest

Source§

impl DataType for BrowseNextResponse

Source§

impl DataType for BrowsePath

Source§

impl DataType for BrowsePathResult

Source§

impl DataType for BrowsePathTarget

Source§

impl DataType for BrowseRequest

Source§

impl DataType for BrowseResponse

Source§

impl DataType for BrowseResult

Source§

impl DataType for Byte

Source§

impl DataType for ByteString

Source§

impl DataType for CallMethodRequest

Source§

impl DataType for CallMethodResult

Source§

impl DataType for CallRequest

Source§

impl DataType for CallResponse

Source§

impl DataType for ContentFilter

Source§

impl DataType for ContentFilterElement

Source§

impl DataType for CreateMonitoredItemsRequest

Source§

impl DataType for CreateMonitoredItemsResponse

Source§

impl DataType for CreateSubscriptionRequest

Source§

impl DataType for CreateSubscriptionResponse

Source§

impl DataType for DataChangeFilter

Source§

impl DataType for DataTypeAttributes

Source§

impl DataType for DataValue

Source§

impl DataType for DateTime

Source§

impl DataType for DeleteMonitoredItemsRequest

Source§

impl DataType for DeleteMonitoredItemsResponse

Source§

impl DataType for DeleteSubscriptionsRequest

Source§

impl DataType for DeleteSubscriptionsResponse

Source§

impl DataType for Double

Source§

impl DataType for EUInformation

Source§

impl DataType for ElementOperand

Source§

impl DataType for EndpointDescription

Source§

impl DataType for EnumDefinition

Source§

impl DataType for EnumField

Source§

impl DataType for Enumeration

Source§

impl DataType for EventFilter

Source§

impl DataType for ExpandedNodeId

Source§

impl DataType for ExtensionObject

Source§

impl DataType for FilterOperator

Source§

impl DataType for Float

Source§

impl DataType for Guid

Source§

impl DataType for Int16

Source§

impl DataType for Int32

Source§

impl DataType for Int64

Source§

impl DataType for IssuedIdentityToken

Source§

impl DataType for LiteralOperand

Source§

impl DataType for LocalizedText

Source§

impl DataType for MessageSecurityMode

Source§

impl DataType for MethodAttributes

Source§

impl DataType for MonitoredItemCreateRequest

Source§

impl DataType for MonitoredItemCreateResult

Source§

impl DataType for MonitoringMode

Source§

impl DataType for MonitoringParameters

Source§

impl DataType for NodeAttributes

Source§

impl DataType for NodeClass

Source§

impl DataType for NodeId

Source§

impl DataType for NodeIdType

Source§

impl DataType for ObjectAttributes

Source§

impl DataType for ObjectTypeAttributes

Source§

impl DataType for QualifiedName

Source§

impl DataType for Range

Source§

impl DataType for ReadRequest

Source§

impl DataType for ReadResponse

Source§

impl DataType for ReadValueId

Source§

impl DataType for ReferenceDescription

Source§

impl DataType for ReferenceTypeAttributes

Source§

impl DataType for RelativePath

Source§

impl DataType for RelativePathElement

Source§

impl DataType for SByte

Source§

impl DataType for SimpleAttributeOperand

Source§

impl DataType for StatusCode

Source§

impl DataType for String

Source§

impl DataType for TimestampsToReturn

Source§

impl DataType for UInt16

Source§

impl DataType for UInt32

Source§

impl DataType for UInt64

Source§

impl DataType for UserNameIdentityToken

Source§

impl DataType for VariableAttributes

Source§

impl DataType for VariableTypeAttributes

Source§

impl DataType for Variant

Source§

impl DataType for ViewAttributes

Source§

impl DataType for WriteRequest

Source§

impl DataType for WriteResponse

Source§

impl DataType for WriteValue

Source§

impl DataType for X509IdentityToken