Repository navigation
feat: refine macros for comprehensive member accessor codegen - #362
Draft
cartercanedy wants to merge 22 commits into
Draft
cartercanedy wants to merge 22 commits into
cartercanedy wants to merge 22 commits into
Conversation
cartercanedy
force-pushed
the
cc/member-accessor-impls
branch
2 times, most recently
from
October 22, 2026 03:58
7af04fa to
9cb5f6a
Compare
cartercanedy
force-pushed
the
cc/member-accessor-impls
branch
from
October 23, 2026 19:23
f156c74 to
98da2de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
open62541holds a pretty high bar with respect to symbol naming consistency, which enables generalizable macros for scaffolding out accessors for each types members.Summary
break up
data_type!macro into 2 macros:data_type_baseline!:the minimal set of trait impls that both stack-bound and pointer-holding types implement via deference to native
open62541impls (e.g.Hash,PartialEq/Eq, etc.) that doesn't impose a defaultDropimplementation.This enables usage of otherwise
const-compatible wrapper types (i.e. completely stack-bound primitive type wrappers) inconstcontexts, and allows use of auto-derivedClone/Copyimplementations (again, useful inconstcontexts).data_type!:The semantics of this macro didn't change, it simply expands
data_type_baseline!before implementingClone&Dropas redirections toUA_copy&UA_clear.Soundness is maintained by compiler enforcement, since
open62541-sys'sbindgenturns off auto-derivation ofClone/Copyfor struct declarations but emits typedefs of primitives as nativepub type UA_<T> = <rust-primitive-dtype>declarations. This still restricts types that may or may not beCopy-safe, but allows for enums & trivially copyable numerics to pass through.member_accessors!macro:*_timestamponDataValue)remove all manually-implemented member accessor implementations in favor of generated methods
Note:
I realize that this is a huge PR to review, so I totally understand if it takes a while. In the spirit of OSS, though, I'm opening this PR since we're relying on these patches downstream in the
instrolibrary, and I'm sure that other consumers of this crate could also benefit from these changes.This is stacked on top of #349. Will rebase as the stack gets whittled down