pub struct Elementor {
pub peer_table: Option<PeerIndexTable>,
}Fields§
§peer_table: Option<PeerIndexTable>Implementations§
Source§impl Elementor
impl Elementor
pub fn new() -> Elementor
Sourcepub fn set_peer_table(&mut self, record: MrtRecord) -> Result<(), ParserError>
pub fn set_peer_table(&mut self, record: MrtRecord) -> Result<(), ParserError>
Sets the peer index table for the elementor.
This method takes an MRT record and extracts the peer index table from it if the record contains one. The peer index table is required for processing TableDumpV2 records, as it contains the mapping between peer indices and their corresponding IP addresses and ASNs.
§Arguments
record- An MRT record that should contain a peer index table
§Returns
Ok(())- If the peer table was successfully extracted and setErr(ParserError)- If the record does not contain a peer index table
§Example
use bgpkit_parser::{BgpkitParser, Elementor};
let mut parser = BgpkitParser::new("rib.dump.bz2").unwrap();
let mut elementor = Elementor::new();
// Get the first record which should be the peer index table
if let Ok(record) = parser.next_record() {
elementor.set_peer_table(record).unwrap();
}Sourcepub fn with_peer_table(peer_table: PeerIndexTable) -> Elementor
pub fn with_peer_table(peer_table: PeerIndexTable) -> Elementor
Creates an Elementor with the given PeerIndexTable already set.
Sourcepub fn record_to_elems_iter(
&self,
record: MrtRecord,
) -> Result<RecordElemIter<'_>, ElemError>
pub fn record_to_elems_iter( &self, record: MrtRecord, ) -> Result<RecordElemIter<'_>, ElemError>
Convert a MrtRecord into an iterator of BgpElems without
requiring &mut self.
Unlike record_to_elems, this method:
- Takes
&selfinstead of&mut self, since the peer table must already be set viaset_peer_tableorwith_peer_table. - Returns an error if the record contains a
PeerIndexTable(which would require mutation). - Returns a lazy
RecordElemIterinstead of collecting into aVec, avoiding allocation for the common RIB table dump case.
§Errors
ElemError::UnexpectedPeerIndexTableif the record is a PeerIndexTable message.ElemError::MissingPeerTableif the record requires a peer table but none is set.
Sourcepub fn bgp_to_elems(
msg: BgpMessage,
timestamp: f64,
peer_ip: &IpAddr,
peer_asn: &Asn,
) -> Vec<BgpElem>
pub fn bgp_to_elems( msg: BgpMessage, timestamp: f64, peer_ip: &IpAddr, peer_asn: &Asn, ) -> Vec<BgpElem>
Convert a BgpMessage to a vector of BgpElems.
A BgpMessage may include Update, Open, Notification or KeepAlive messages,
and only Update message contains BgpElems.
Sourcepub fn bgp_to_elems_iter(
msg: BgpMessage,
timestamp: f64,
peer_ip: &IpAddr,
peer_asn: &Asn,
) -> Option<BgpUpdateElemIter>
pub fn bgp_to_elems_iter( msg: BgpMessage, timestamp: f64, peer_ip: &IpAddr, peer_asn: &Asn, ) -> Option<BgpUpdateElemIter>
Convert a BgpMessage into an iterator of BgpElems.
Returns None for non-Update messages (Open, Notification, KeepAlive).
Sourcepub fn bgp_update_to_elems(
msg: BgpUpdateMessage,
timestamp: f64,
peer_ip: &IpAddr,
peer_asn: &Asn,
) -> Vec<BgpElem>
pub fn bgp_update_to_elems( msg: BgpUpdateMessage, timestamp: f64, peer_ip: &IpAddr, peer_asn: &Asn, ) -> Vec<BgpElem>
Convert a BgpUpdateMessage to a vector of BgpElems.
Sourcepub fn bgp_update_to_elems_iter(
msg: BgpUpdateMessage,
timestamp: f64,
peer_ip: &IpAddr,
peer_asn: &Asn,
) -> BgpUpdateElemIter ⓘ
pub fn bgp_update_to_elems_iter( msg: BgpUpdateMessage, timestamp: f64, peer_ip: &IpAddr, peer_asn: &Asn, ) -> BgpUpdateElemIter ⓘ
Convert a BgpUpdateMessage into a BgpUpdateElemIter that lazily
yields BgpElems without allocating a Vec.
Sourcepub fn record_to_elems(&mut self, record: MrtRecord) -> Vec<BgpElem>
pub fn record_to_elems(&mut self, record: MrtRecord) -> Vec<BgpElem>
Convert a MrtRecord to a vector of BgpElems.
If the record is a PeerIndexTable, it is consumed to set the internal
peer table. Errors are logged.
For a non-mutating, lazy alternative, see
record_to_elems_iter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Elementor
impl RefUnwindSafe for Elementor
impl Send for Elementor
impl Sync for Elementor
impl Unpin for Elementor
impl UnsafeUnpin for Elementor
impl UnwindSafe for Elementor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more