bgpkit-parser is a Rust library for parsing MRT/BGP/BMP data. It provides both a library API and a CLI (bgpkit-parser binary).
Key features defined in Cargo.toml:
default—parser+rustlsparser— core parsing (bytes, chrono, regex, zerocopy)cli— command-line interface (clap, env_logger, serde, serde_json)rislive— RIS Live WebSocket support (serde, serde_json, hex)serde— serialization supportlocal— local-file parsing helperswasm— WebAssembly bindingsts-rs— TypeScript type generation for the WASM bindingsnative-tls/rustls— TLS backend selectionxz/lz— optional compression algorithms
Always build with --all-features and include examples:
cargo build --all-features --examples
Always run tests with --all-features:
cargo test --all-features
Always run clippy with --all-features:
cargo clippy --all-features
The pre-push hook uses the stricter form below; run it before pushing if you want to match the exact CI check:
cargo clippy --all-targets --all-features -- -D warnings
cargo fmt does not accept --all-features (formatting is feature-independent):
cargo fmt
To check formatting without modifying files:
cargo fmt -- --check
README.md is auto-generated from src/lib.rs doc comments via cargo-readme.
- Edit documentation in
src/lib.rs(inside the top-level//!doc comment block), not inREADME.mddirectly. - After editing
src/lib.rs, regenerateREADME.md:cargo readme > README.md - The pre-push hook runs a
cargo readmediff check; ifREADME.mdis out of sync withsrc/lib.rs, the push will be rejected. - If you do not have
cargo-readmeinstalled:cargo install cargo-readme
A .git/hooks/pre-push script performs three checks in order. It is a local hook: it is not versioned in this repository (a fresh clone only has .git/hooks/pre-push.sample), pull-request CI does not run the README check (only the release workflow does, at tag time), so run these commands yourself before pushing changes that touch src/lib.rs:
- Formatting:
cargo fmt --check - README sync:
cargo readme > TMP_README.md && diff -b TMP_README.md README.md - Clippy:
cargo clippy --all-targets --all-features -- -D warnings
If any check fails, the push is aborted. Fix the issue, commit, and push again.
CI uploads coverage to Codecov on every push and PR. The codecov.yml at the repo root configures ignored paths, thresholds, and PR comment layout.
Use scripts/coverage-misses.sh to get exact line numbers for uncovered patch lines via the public Codecov API v2 (no token needed):
./scripts/coverage-misses.sh <PR_NUMBER>Example output:
📄 src/parser/bgp/attributes/attr_26_aigp.rs
Coverage: 85.29% | Patch misses: 10 lines
Uncovered lines: 20, 21, 22, 27, 28, 29, 30, 50, 76, 91
This is more actionable than the Codecov PR comment, which only shows miss counts with links to codecov.io. After running the script, use read on the file to inspect the uncovered lines.
The script calls:
GET /compare/impacted_files?pullid=N— lists files with patch missesGET /compare/segments/{file_path}?pullid=N— returns line-by-line coverage (head_coverage: 1= uncovered,0= covered,null= non-code)
These endpoints are public and documented at https://docs.codecov.com/reference.
Before pushing a new feature, run the script on your PR to identify lines that need tests. The pre-push hook does NOT gate on coverage — coverage checks in CI are informational (non-blocking, 10% threshold).
- The
bgpkit-parserbinary requires theclifeature (required-features = ["cli"]). - Examples under
examples/may require specific features (see[[example]]entries inCargo.toml). - Benchmarks use Criterion (
[[bench]]entries).
When documenting changes in CHANGELOG.md:
- Contributor attribution: Credit external contributors in a
### Contributorssubsection at the end of the release section, linking each contributor's handle to their PRs — do not append per-entry thanks to individual bullets.- Example:
* @ties — route-level parser ([#310](https://github.com/bgpkit/bgpkit-parser/pull/310)) - Use plain
@handletext (not markdown links like[@ties](https://github.com/ties)) — the automated release tool copies CHANGELOG verbatim, and the Contributors section flows into the GitHub release notes.
- Example:
When looking for incomplete or missing BGP attribute implementations, check src/parser/bgp/attributes/README.md. This file contains:
- Unit Test Coverage table — lists fully implemented attributes with RFC references
- Known Limitations table — lists attributes that are:
- Type defined in
AttrTypeenum but have no parser (e.g., PMSI_TUNNEL, BGPSEC_PATH) - Model structs exist but parser/encoder not yet implemented (e.g., AIGP, ATTR_SET)
- Type defined in
Use this file to identify which attributes need implementation work and their corresponding RFCs.