Thank you for your interest in contributing to lib3mf_rust! This document provides guidelines for contributing to the project.
This project follows the Rust Code of Conduct. Please be respectful and constructive in all interactions.
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/lib3mf_rust.git - Create a new branch:
git checkout -b feature/your-feature-name - Make your changes
- Test your changes
- Submit a pull request
- Rust 1.70 or later
- Git
cargo build# Run all tests
cargo test
# Run conformance tests
cargo test --test conformance_tests summary -- --ignored --nocapture
# Run specific test suite
cargo test --test conformance_tests suite3_core -- --nocapturecargo clippy -- -D warningscargo bench- Follow standard Rust conventions (use
rustfmt) - Use meaningful variable names that reflect 3MF terminology
- Prefer explicit types over type inference when it improves clarity
- NO unsafe code allowed - forbidden at crate level with
#![forbid(unsafe_code)]
- Use
Result<T, Error>for all fallible operations - Return descriptive errors using the
Errorenum defined inerror.rs - Use
thiserrorfor custom error types - Include context in error messages (e.g., file paths, element names)
- Unit tests: Test individual functions and modules in the same file using
#[cfg(test)] - Integration tests: Test complete workflows in
tests/directory - Conformance tests: Official 3MF Consortium test suites
- Examples: Working code in
examples/that demonstrates features - Always run clippy before committing:
cargo clippy -- -D warnings
- Add doc comments (
///) for all public APIs - Include usage examples in doc comments where helpful
- Keep README.md updated with new features
- Document complex algorithms with inline comments
- Use 3MF specification terminology (e.g.,
objectid,pid,requiredextensions) - Follow Rust naming:
snake_casefor functions/variables,PascalCasefor types - Struct field names match 3MF XML attribute names when possible
- Constants use
UPPER_SNAKE_CASE
- Run all tests: Ensure
cargo testpasses - Run clippy: Fix all warnings with
cargo clippy -- -D warnings - Format code: Run
cargo fmt - Update documentation: If you add features, update README.md and relevant docs
- Add examples: For new features, add examples in
examples/ - Update CHANGELOG.md: Add your changes under "Unreleased"
- Ensure your PR has a clear title and description
- Reference any related issues
- Include test results if applicable
- For user-facing changes, update documentation
- Add benchmark results for performance-sensitive changes
- Wait for CI checks to pass
- Address any review feedback
- Write clear, concise commit messages
- Use the imperative mood ("Add feature" not "Added feature")
- First line should be 50 characters or less
- Include more details in the body if needed
Example:
Add support for displacement extension
- Implement displacement map parsing
- Add displacement coordinate groups
- Update conformance tests
When adding support for a new 3MF extension:
- Add types to
src/model.rs - Implement parsing in
src/parser.rs - Add validation in
src/validator.rs - Create integration tests
- Update documentation in README.md
- Add conformance tests if available
- Add examples demonstrating the feature
- Parsing should scale linearly with file size
- Use pre-allocated buffers where possible
- Profile with
cargo benchfor performance-critical code - Avoid unnecessary allocations in hot paths
# Run a specific test
cargo test test_name
# Run tests with output
cargo test -- --nocapture
# Run integration tests
cargo test --test integration_test_nameThis library is validated against the official 3MF Consortium test suites. To run conformance tests:
# Run all conformance tests
cargo test --test conformance_tests summary -- --ignored --nocapture
# Run specific suite
cargo test --test conformance_tests suite3_core -- --nocaptureIf you discover a security vulnerability, please do not open a public issue. Instead, please email the maintainers directly or use GitHub's private security advisory feature.
- Never add unsafe code (enforced by
#![forbid(unsafe_code)]) - Validate all XML input thoroughly
- Check array bounds and prevent integer overflows
- Validate resource ID references to prevent infinite loops
- Handle ZIP bomb scenarios
- Never commit secrets or credentials
- Check existing issues
- Read the README.md and code documentation
- Look at examples for usage patterns
- Review the 3MF specification
By contributing to lib3mf_rust, you agree that your contributions will be licensed under the MIT License, the same as the project.