oxidecomputer / oxidecomputer/maghemite
bgp: want encoding methods (.to_wire()) to all be infallible
@nicolaskagami is already working on this.
Since Jul 1, 2026.
- Dominant language
- Rust
- Stars
- 94
- Forks
- 6
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 12
Description
Surprisingly, many of the encoding methods are fallible. IMO this should not be handled at this layer, as semantic validation and structuring of types should be handled during type instantiation rather than during serialization of an instance of that type.
Looking through bgp/src/messages.rs I see the following examples of .to_wire() returning a Result<Vec<u8>> rather than just a Vec<u8>:
Message.to_wire()OpenMessage.to_wire()UpdateMessage.to_wire()PathAttribute.to_wire()PathAttributeValue.to_wire()As4PathSegment.to_wire()MpUnreachNlri.to_wire()NotificationMessage.to_wire()OptionalParameter.to_wire()Capability.to_wire()
These could all be modified to push the fallibility onto the creator of the type rather than the encoder.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.