bgpflux 0.3.0

A Rust library and CLI for streaming ordered BGP elements from multiple collectors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use chrono::NaiveDateTime;
use regex::Regex;
use std::sync::LazyLock;

static TIMESTAMP_PATTERN: LazyLock<Regex> =
    LazyLock::new(|| Regex::new(r"(\d{8}\.\d{4})\.(?:gz|bz2)").unwrap());

pub fn timestamp_from_project_url(url: &str) -> Option<i64> {
    let caps = TIMESTAMP_PATTERN.captures(url)?;
    let time_str = caps.get(1)?.as_str();
    NaiveDateTime::parse_from_str(time_str, "%Y%m%d.%H%M")
        .ok()
        .map(|t| t.and_utc().timestamp())
}