How hawkeyes1094/crlite-python works
Project type and purpose
• Project type: An open-source Python package that provides CRLite support by wrapping a Rust library (crlite-clubcard) via PyO3.
• Purpose: Allow Python developers to load and query Mozilla’s Clubcard filter files (used for efficient certificate revocation checks) through a clean Python API.
File structure
• Top-level:
• Cargo.toml, src/lib.rs → Rust library crate (the PyO3 binding layer sits here).
• pyproject.toml, python/… → Python package source (crlite_python), setup, and metadata.
• requirements.txt, sample.py → Python dependencies and example usage.
• tests/test_all.py → End-to-end tests covering both Python API and underlying Rust logic.
• .github/workflows/CI.yml → CI pipeline building Rust, running Python tests, publishing.
• Key patterns:
• Hybrid Rust/Python codebase via PyO3.
• Clear separation: Rust core logic in src/lib.rs; Python wrappers in python/crlite_python/*.
• Build artifacts managed by Cargo (Rust) and pip/pyproject for Python.
README for additional insights
• Describes use of Mozilla’s Clubcard CRLite filters.
• Indicates Rust dependency (crlite-clubcard) and PyO3 binding approach.
a. Main components
1. Python Application Layer
2. PyO3 Binding Layer
3. Rust Library (crlite-clubcard)
4. External Data Source (Mozilla Clubcard filter files)
5. Build/CI System (GitHub Actions)
b. Relationships and interactions
• The Python API invokes functions in the PyO3 binding.
• PyO3 marshals data and calls into the Rust library.
• The Rust library loads/parses filter files and runs certificate lookup algorithms.
• External data (filter files) are downloaded or loaded at runtime by the Rust layer.
• CI pipeline builds Rust wheels, installs Python deps, and runs tests end to end.
c. Architectural patterns and design principles
• Language interoperability: PyO3 FFI bridging Python ↔ Rust.
• Single-responsibility: Python code handles user-facing API and packaging; Rust code handles heavy-weight filter logic.
• CI automation ensures consistency across platforms (Linux, macOS, Windows).
d. Key technologies and frameworks
• Python 3.x, setuptools/pyproject.toml
• PyO3 for FFI
• Rust, Cargo.toml for dependency management
• GitHub Actions for CI/CD