pub struct NotificationMessage {
pub code: NotificationCode,
pub subcode: u8,
pub data: Bytes,
}Expand description
A decoded BGP NOTIFICATION message (RFC 4271 §4.5).
Fields§
§code: NotificationCodeError code identifying the type of error.
subcode: u8Error subcode providing more specific information.
data: BytesDiagnostic data (contents depend on code/subcode).
Implementations§
Source§impl NotificationMessage
impl NotificationMessage
Sourcepub fn decode(buf: &mut impl Buf, body_len: usize) -> Result<Self, DecodeError>
pub fn decode(buf: &mut impl Buf, body_len: usize) -> Result<Self, DecodeError>
Decode a NOTIFICATION message body from a buffer.
The header must already be consumed; body_len is
header.length - HEADER_LEN.
§Errors
Returns DecodeError::MalformedField if the body is too short, or
DecodeError::Incomplete if the buffer has fewer bytes than body_len.
Sourcepub fn encode_body(&self, buf: &mut impl BufMut)
pub fn encode_body(&self, buf: &mut impl BufMut)
Encode a NOTIFICATION message body into a buffer. Does NOT write the header — call this after encoding the header.
Sourcepub fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
pub fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
Encode a complete NOTIFICATION message (header + body).
§Errors
Returns EncodeError::MessageTooLong if the encoded message exceeds
the maximum BGP message size.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Total encoded size in bytes.
Sourcepub fn new(code: NotificationCode, subcode: u8, data: Bytes) -> Self
pub fn new(code: NotificationCode, subcode: u8, data: Bytes) -> Self
Convenience: build a NOTIFICATION from code, subcode, and data.
Trait Implementations§
Source§impl Clone for NotificationMessage
impl Clone for NotificationMessage
Source§fn clone(&self) -> NotificationMessage
fn clone(&self) -> NotificationMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more