Welcome to the BgUtils POT Provider Rust implementation! This document provides guidelines for contributing to the project.
Before contributing, ensure you have the following installed:
- Rust: Version 1.85+ with edition 2024 support
- Git: For version control
- System dependencies:
jqandbc(for coverage checking)- Standard development tools for your platform
If you don't have Rust installed, visit rustup.rs for installation instructions.
# Verify Rust installation
rustc --version
cargo --version# Install development tools
cargo install cargo-nextest --locked # Fast test runner
cargo install cargo-llvm-cov # Code coverage
# Install system dependencies (Ubuntu/Debian)
sudo apt install jq bc
# Install system dependencies (macOS)
brew install jq bcThis script will automatically copy the current working directory's plugin to one of the default yt-dlp plugin directory at ~/yt-dlp-plugins. Use it for quick development setup:
bash scripts/install_plugin_dev.sh# Development build
cargo build
# Release build
cargo build --release
# Build binary
cargo build --bin bgutil-pot# Run HTTP server
cargo run --bin bgutil-pot -- server
# Generate POT token (script mode)
cargo run --bin bgutil-pot -- --content-binding "VIDEO_ID"This project maintains high code quality standards through automated tooling and conventions.
Code formatting is enforced using rustfmt with project-specific configuration in rustfmt.toml:
# Format all code
cargo fmt
# Check formatting without making changes
cargo fmt -- --checkWe use clippy for code linting with strict warning levels:
# Run clippy checks
cargo clippy --all-features -- -D warnings
# Run clippy for all targets
cargo clippy --all-targets --all-features -- -D warningsUse our comprehensive quality check script before submitting code:
# Run all quality checks
./scripts/quality_check.sh
# Run with verbose output
./scripts/quality_check.sh --verbose
# Run with full test profile (longer timeouts)
./scripts/quality_check.sh --fullThis script performs:
- Compilation checks
- Code formatting validation
- Clippy linting
- Documentation generation
- Documentation example testing
- Unit and integration tests
# Run all tests (fast)
cargo nextest run
# Run all tests (with full profile for longer timeouts)
cargo nextest run --profile full
# Run specific test
cargo nextest run -E 'test(test_name)'
# Run tests for specific package
cargo nextest run -p bgutil-ytdlp-pot-provider- Unit tests: Located alongside source code
- Integration tests: Located in
tests/directory - Documentation tests: Embedded in documentation comments
Monitor test coverage using our coverage script:
# Check coverage with default threshold (75%)
./scripts/check_coverage.sh
# Check with custom threshold
./scripts/check_coverage.sh --threshold 80
# Show coverage table for all files
./scripts/check_coverage.sh --table
# Generate LCOV output
./scripts/check_coverage.sh --lcov coverage.infoAll public APIs must be documented using rustdoc comments:
/// Brief description of the function
///
/// # Arguments
///
/// * `param` - Description of the parameter
///
/// # Returns
///
/// Description of the return value
///
/// # Examples
///
/// ```
/// let result = function_name(param);
/// assert_eq!(result, expected_value);
/// ```
pub fn function_name(param: Type) -> ReturnType {
// Implementation
}# Generate documentation
cargo doc --all-features --no-deps --document-private-items
# Generate and open documentation
cargo doc --all-features --no-deps --document-private-items --open
# Test documentation examples
cargo test --doc --all-featuressrc/: Main Rust source codemain.rs: Unified CLI entry point with server and generate subcommandsconfig/: Configuration managementserver/: HTTP server implementationsession/: POT token generation logictypes/: Type definitionsutils/: Utility functions
tests/: Integration testsscripts/: Development and automation scriptsplugin/: Python yt-dlp plugin (read-only)docs/: Project documentation
- Modularity: Each module has a single, well-defined responsibility
- Error Handling: Use
Result<T, E>and proper error types - Async/Await: Use
tokiofor async operations - Configuration: Support multiple configuration sources (CLI, env, file)
- Testing: Write comprehensive tests for all functionality
Follow conventional commit format:
type(scope): brief description
Detailed description if needed
Closes #issue_number
Types:
feat: New featuresfix: Bug fixesdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Test additions or modificationschore: Maintenance tasks
Examples:
feat(server): add health check endpoint
Add /health endpoint for monitoring server status
Closes #123
fix(session): resolve token expiration handling
Improve token refresh logic to handle edge cases
where tokens expire during generation
Closes #456
Always ensure your code passes all quality checks before committing:
# Run quality checks
./scripts/quality_check.sh
# Stage changes
git add .
# Commit with proper message
git commit -m "feat(component): description"- Fork the repository
- Create a feature branch from
master - Implement your changes following the guidelines above
- Run all quality checks:
./scripts/quality_check.sh - Write tests for new functionality
- Update documentation if needed
- Submit a pull request with a clear description
- All quality checks must pass
- Test coverage should not decrease
- Documentation must be updated for new features
- Commit messages follow conventional format
- No merge conflicts with master branch
# Enable debug logging
export RUST_LOG=debug
# Set custom server configuration
export POT_SERVER_HOST="127.0.0.1"
export POT_SERVER_PORT="8080"# Run with debug output
RUST_LOG=debug cargo run --bin bgutil-pot -- server
# Build with debug info
cargo build --bin bgutil-pot# Build with release optimizations
cargo build --release
# Profile with criterion (if benchmarks exist)
cargo bench- Issues: Check existing GitHub issues
- Documentation: See the
docs/directory - Code Examples: Check the
examples/directory
By contributing to this project, you agree that your contributions will be licensed under the GPL-3.0-or-later License.