Skip to content

bgp: want encoding methods (.to_wire()) to all be infallible #615

@taspelund

Description

@taspelund

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bgpBorder Gateway Protocolwant

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions