HMIProject / open62541

11 stars 6 forks source link

Add `ua::NodeId::null` #134

Closed LeanderGlanda closed 3 months ago

LeanderGlanda commented 3 months ago

Requires #128 Required by #133

LeanderGlanda commented 3 months ago

open62541's __UA_Server_addNode requires the typeDefinition parameter. When adding a node with Object, ObjectType, or VariableType attributes, the typeDefinition is required, otherwise a numeric NodeId with 0's as values should be passed. At least this is how it is done when the e.g. UA_Server_addObjectTypeNode is called. That's what this is used for.

In the Node struct I used the type Option<NodeContext>. When the typeDefinition is required, my code in #126 expects Some(), otherwise / when None() is passed, ua::NodeId::null() was called to pass an empty NodeId.

In theory the code could just generate an all 0 numeric node everytime a "null" nodeid is required. But as the C code also implements a UA_NODEID_NULL type, having this in this code base would stay closer to the original.

sgoll commented 3 months ago

Thank you for the explanation. So for a purely internal helper method, I'd suggest using visibility pub(crate) instead of pub. In the external interface, I'd try to use Option<ua::NodeId> instead.

Can you rebase this PR so that it only contains the changes to ua::NodeId, so that we can merge that directly?

LeanderGlanda commented 3 months ago

Thanks for the feedback, that sounds good.

Yes, I'll do that, no problem.