You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Add public accessor method for NodeId to extract inner usize value #112
This makes it difficult for users of the library to:
Serialize node IDs to external formats (JSON, databases, etc.)
Use node IDs in external logging/monitoring systems that expect numeric identifiers
Interface with other systems that require numeric IDs
Debug and inspect node ID values programmatically
Currently, the only way to see the value is through Debug formatting ({:?}), which is fragile and not suitable for programmatic access.
Proposed Solution
Add a public accessor method to the NodeId struct:
implNodeId{pubfnas_usize(&self) -> usize{self.0}}
This follows common Rust patterns for newtype wrappers (similar to NonZeroUsize::get(), etc.) and maintains the type safety of NodeId while providing controlled access to the underlying value when needed.
Alternatives Considered
Make the field public (pub usize) - This would weaken the encapsulation and type safety that the newtype pattern provides.
Implement From<NodeId> for usize - This works but consumes the NodeId (though it's Copy, so not a real issue). The explicit method is more discoverable.
Hi! We added both NodeId::as_usize() and a From<NodeId> for usize implementation (#113) so callers can safely obtain the numeric ID. Thanks for your issue :)
Activity
191220029 commentedon Nov 27, 2025
Hi! We added both
NodeId::as_usize()and aFrom<NodeId> for usizeimplementation (#113) so callers can safely obtain the numeric ID. Thanks for your issue :)dsaad68 commentedon Dec 1, 2025
Thanks, a lot!