pub trait BinaryEncodable {
// Required methods
fn byte_len(&self, ctx: &Context<'_>) -> usize;
fn encode<S: Write + ?Sized>(
&self,
stream: &mut S,
ctx: &Context<'_>,
) -> EncodingResult<()>;
// Provided methods
fn override_encoding(&self) -> Option<BuiltInDataEncoding> { ... }
fn encode_to_vec(&self, ctx: &Context<'_>) -> Vec<u8> ⓘ { ... }
}Expand description
OPC UA Binary Encoding interface. Anything that encodes to binary must implement this. It provides functions to calculate the size in bytes of the struct (for allocating memory), encoding to a stream and decoding from a stream.
§Implementing
The majority of implementers should just use the derive(BinaryEncodable) macro,
if you need to implement this yourself for some reason, the following must be satisfied:
byte_lenmust return a length exactly equal to whatencodewill write, orencodemust be guaranteed to fail. Sincebyte_lenis infallible, you are allowed to return some invalid value there, then fail later when callingencode. This should be avoided.encodemust usewrite_allon the stream, not justwrite, to ensure that all the data is written, even if the stream is interrupted. Prefer callingencodeon inner types instead.
Required Methods§
Provided Methods§
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.
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.
Implementations on Foreign Types§
Source§impl<T> BinaryEncodable for Option<Vec<T>>where
T: BinaryEncodable,
impl<T> BinaryEncodable for Option<Vec<T>>where
T: BinaryEncodable,
Implementors§
impl BinaryEncodable for ActionState
impl BinaryEncodable for ApplicationType
impl BinaryEncodable for AxisScaleEnumeration
impl BinaryEncodable for BrokerTransportQualityOfService
impl BinaryEncodable for BrowseDirection
impl BinaryEncodable for BrowseResultMask
impl BinaryEncodable for ChassisIdSubtype
impl BinaryEncodable for ConversionLimitEnum
impl BinaryEncodable for DataChangeTrigger
impl BinaryEncodable for DataSetOrderingType
impl BinaryEncodable for DeadbandType
impl BinaryEncodable for DiagnosticsLevel
impl BinaryEncodable for Duplex
impl BinaryEncodable for ExceptionDeviationFormat
impl BinaryEncodable for FilterOperator
impl BinaryEncodable for HistoryUpdateType
impl BinaryEncodable for IdType
impl BinaryEncodable for IdentityCriteriaType
impl BinaryEncodable for InterfaceAdminStatus
impl BinaryEncodable for InterfaceOperStatus
impl BinaryEncodable for ManAddrIfSubtype
impl BinaryEncodable for MessageSecurityMode
impl BinaryEncodable for ModelChangeStructureVerbMask
impl BinaryEncodable for MonitoringMode
impl BinaryEncodable for NamingRuleType
impl BinaryEncodable for NegotiationStatus
impl BinaryEncodable for NodeAttributesMask
impl BinaryEncodable for NodeClass
impl BinaryEncodable for OpenFileMode
impl BinaryEncodable for OverrideValueHandling
impl BinaryEncodable for PerformUpdateType
impl BinaryEncodable for PortIdSubtype
impl BinaryEncodable for PubSubDiagnosticsCounterClassification
impl BinaryEncodable for PubSubState
impl BinaryEncodable for RedundancySupport
impl BinaryEncodable for RedundantServerMode
impl BinaryEncodable for SecurityTokenRequestType
impl BinaryEncodable for ServerState
impl BinaryEncodable for SortOrderType
impl BinaryEncodable for StructureType
impl BinaryEncodable for TimestampsToReturn
impl BinaryEncodable for TrustListMasks
impl BinaryEncodable for TsnFailureCode
impl BinaryEncodable for TsnListenerStatus
impl BinaryEncodable for TsnStreamState
impl BinaryEncodable for TsnTalkerStatus
impl BinaryEncodable for UserTokenType
impl BinaryEncodable for Variant
impl BinaryEncodable for Argument
impl BinaryEncodable for DynamicStructure
impl BinaryEncodable for DataValue
impl BinaryEncodable for DateTime
DateTime encoded as 64-bit signed int