Thank you for your interest in contributing to netflow_parser! This document provides guidelines and workflows for contributors.
- Rust stable (latest version recommended)
- Git
git clone https://github.com/mikemiles-dev/netflow_parser.git
cd netflow_parser
cargo build
cargo testWe provide Git hooks to help catch issues before committing:
./scripts/install-hooks.shThis installs a pre-commit hook that:
- Runs doc tests when documentation files are modified
- Reminds you to sync README.md and src/lib.rs
Important: We maintain documentation in two places that must stay synchronized:
src/lib.rs- Rust doc comments (source of truth for rustdoc)README.md- GitHub README (for crates.io and repository visibility)
When updating documentation, follow this workflow:
Make your documentation changes in the Rust doc comments:
//! ## Your Section
//!
//! Your documentation here...
//!
//! ```rust
//! // Your example code
//! ```
Copy the same content to README.md (without the //! prefix):
## Your Section
Your documentation here...
```rust
// Your example code
#### 3. Test Documentation
Run doc tests to ensure all examples compile:
```bash
cargo test --doc
Run the sync checker:
./scripts/check-readme-sync.shThis script:
- ✓ Runs doc tests
- ✓ Compares section headers
- ✓ Checks for common sync issues
- ✓ Verifies Table of Contents
- Keep Examples Minimal: Show only what's necessary to demonstrate the feature
- Test Examples: All code examples must compile (use doc tests)
- Use
ignoretag sparingly: Only for pseudo-code or incomplete examples - Update Table of Contents: When adding new sections, update the TOC in README.md
- Section Order: Keep sections in the same order in both files
Both src/lib.rs and README.md should follow this structure:
- Example
- Serialization (JSON)
- Filtering for a Specific Version
- Iterator API
- Parsing Out Unneeded Versions
- Error Handling Configuration
- Netflow Common
- Re-Exporting Flows
- Template Cache Configuration
- V9/IPFIX Notes
- Performance & Thread Safety
- Features
- Included Examples
cargo testcargo test --doccargo test test_nameRun all benchmarks (excluding feature-gated benchmarks):
cargo benchRun all benchmarks including netflow_common_bench (requires netflow_common feature):
cargo bench --all-featuresRun a specific benchmark:
# Standard benchmarks (no features required)
cargo bench --bench netflow_parser_bench
cargo bench --bench netflow_v5_bench
cargo bench --bench netflow_v9_bench
cargo bench --bench netflow_ipfix_bench
cargo bench --bench packet_size_bench
# Feature-gated benchmark (requires netflow_common feature)
cargo bench --bench netflow_common_bench --features netflow_commonWe use rustfmt for code formatting:
cargo fmtWe use clippy for additional linting:
cargo clippy --allEnsure these pass:
cargo fmt --check
cargo clippy --all
cargo test
cargo test --doc
./scripts/check-readme-sync.shOr use the pre-commit hook (recommended):
./scripts/install-hooks.sh-
Fork the repository and create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes following the guidelines above
-
Test thoroughly:
cargo test cargo test --doc cargo clippy --all ./scripts/check-readme-sync.sh
-
Commit your changes:
git add . git commit -m "feat: description of your changes"
Use conventional commit messages:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Test additions/changesrefactor:- Code refactoringperf:- Performance improvements
-
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub
- Clear description of changes
- Motivation/reasoning for changes
- Any breaking changes highlighted
- Tests for new functionality
- Updated documentation (both lib.rs and README.md)
Your PR must pass these automated checks:
- ✓
cargo fmt --check- Code formatting - ✓
cargo clippy --all- Linting - ✓
cargo build- Compilation - ✓
cargo test- Unit tests - ✓
cargo test --doc- Documentation tests - ✓
./scripts/check-readme-sync.sh- Documentation sync - ✓
cargo bench- Benchmarks
We provide several helper scripts in scripts/:
check-readme-sync.sh- Verifies README.md and src/lib.rs are in syncinstall-hooks.sh- Installs Git pre-commit hookspre-commit- Pre-commit hook (checks doc tests)
GitHub Actions automatically runs all checks on:
- Every push to
mainbranch - Every pull request to
mainbranch
See .github/workflows/rust.yml for details.
- Issues: Open an issue on GitHub for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
- Documentation: Check the README and rustdoc
Be respectful and constructive in all interactions. We're here to build great software together!
By contributing, you agree that your contributions will be licensed under the same license as the project.
Thank you for contributing to netflow_parser! 🎉