Skip to content

Reduce unsafe code in codec through better abstractions#29

Merged
gerben-stavenga merged 2 commits intomasterfrom
improve-unsafe-use
Jan 4, 2026
Merged

Reduce unsafe code in codec through better abstractions#29
gerben-stavenga merged 2 commits intomasterfrom
improve-unsafe-use

Conversation

@gerben-stavenga
Copy link
Copy Markdown
Owner

@gerben-stavenga gerben-stavenga commented Jan 4, 2026

Remove unnecessary static from serde impl, that remove unnecessary unsafe + cargo fmt

- Add Ptr<T> and PtrMut<T> types that encapsulate pointer validity invariant
- Add UpdateByValue trait for safe struct field updates
- Use Message type instead of raw *mut Object in decoder
- Fix lifetimes in set_bytes/add_bytes to eliminate transmute
- Check field presence before accessing oneof data in reflection

Reduces unsafe blocks in decoding.rs from 15 to 4 and encoding.rs from 11 to 2.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gerben-stavenga gerben-stavenga merged commit e51dec7 into master Jan 4, 2026
2 checks passed
@gerben-stavenga gerben-stavenga deleted the improve-unsafe-use branch January 4, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant