locka99 / opcua

A client and server implementation of the OPC UA specification written in Rust
Mozilla Public License 2.0
496 stars 131 forks source link

Enumerations changed #109

Open schroeder- opened 3 years ago

schroeder- commented 3 years ago

First of thanks for this great library. Its easy to get started and get thinks working.

I am building an OPCUA Pubsub library based on this crate. While doing so i noticed something with enumerations. I think in the 1.03 OPCUA specs enums should be encoded as i32 and should be single values. With the 1.04 specs the length of an enum is specified in opc.ua.types.xsd as "LengthInBits". It's not possible to encode/decode a FieldMetaData because it contains DataSetFieldFlags.

Also some enums now can be bitflags, they are marked with "IsOptionSet". They should be implemente as bitflags! instead of enum.

example:

  <opc:EnumeratedType Name="DataSetFieldFlags" LengthInBits="16" IsOptionSet="true">
    <opc:EnumeratedValue Name="None" Value="0" />
    <opc:EnumeratedValue Name="PromotedField" Value="1" />
  </opc:EnumeratedType>
locka99 commented 3 years ago

I'll leave this open to take a look at it. Up until now all the enums have been the same length so it hasn't required any special code.