中文版 | English
Thank you for your interest in contributing to Rustun! We welcome contributions from everyone.
- Code of Conduct
- How Can I Contribute?
- Development Setup
- Coding Guidelines
- Commit Messages
- Pull Request Process
- Reporting Bugs
- Suggesting Enhancements
This project follows a Code of Conduct that all contributors are expected to adhere to. Please be respectful and constructive in all interactions.
If you find a bug, please create an issue with:
- Clear title and description
- Steps to reproduce the problem
- Expected behavior vs actual behavior
- Environment details (OS, Rust version, etc.)
- Relevant logs or error messages
We welcome feature requests! Please:
- Check if the feature is already requested in Issues
- Provide a clear use case and description
- Explain why this feature would be useful
- Consider implementation approaches
- Bug fixes - Always welcome!
- New features - Please discuss in an issue first
- Documentation - Improvements to docs are highly valued
- Tests - Adding test coverage is greatly appreciated
- Rust 1.70 or higher
- Git
- Docker (for cross-compilation testing)
# Clone the repository
git clone https://github.com/smartethnet/rustun.git
cd rustun
# Build the project
cargo build
# Run tests
cargo test
# Run lints
cargo clippy -- -D warnings
# Format code
cargo fmtWe recommend installing these tools:
# Auto-reload on file changes
cargo install cargo-watch
# Better test output
cargo install cargo-nextest
# Dependency management
cargo install cargo-edit# Run server with auto-reload
cargo watch -x 'run --bin server -- etc/server.toml'
# Run client with auto-reload
cargo watch -x 'run --bin client -- -s 127.0.0.1:8080 -i test-client'- Follow the Rust API Guidelines
- Use
cargo fmtfor consistent formatting - Ensure
cargo clippypasses without warnings - Write idiomatic Rust code
src/
├── client/ # Client-side code
├── server/ # Server-side code
├── codec/ # Protocol encoding/decoding
├── crypto/ # Encryption implementations
├── network/ # Network abstractions
└── utils/ # Shared utilities
-
Error Handling
- Use
Resultand?operator - Provide meaningful error messages
- Avoid
unwrap()in production code
- Use
-
Documentation
- Add doc comments for public APIs
- Include examples in documentation
- Update README.md when adding features
-
Testing
- Write unit tests for new functions
- Add integration tests for features
- Ensure tests pass before submitting
-
Performance
- Avoid unnecessary allocations
- Use async/await properly
- Profile before optimizing
/// Encrypts data using the configured cipher
///
/// # Arguments
/// * `data` - The plaintext data to encrypt
///
/// # Returns
/// * `Ok(Vec<u8>)` - The encrypted ciphertext
/// * `Err(CryptoError)` - If encryption fails
///
/// # Example
/// ```
/// let encrypted = encrypt(b"hello")?;
/// ```
pub fn encrypt(&self, data: &[u8]) -> Result<Vec<u8>, CryptoError> {
// Implementation
}We follow the Conventional Commits specification:
<type>(<scope>): <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasks
# Good commit messages
feat(client): add keepalive configuration options
fix(server): handle connection timeout correctly
docs(readme): update installation instructions
refactor(crypto): simplify encryption interface
# Bad commit messages
fix bug
update code
changes- Use present tense ("add" not "added")
- Use imperative mood ("move" not "moves")
- Limit first line to 72 characters
- Reference issues with
#issue-number
-
Fork the repository
-
Create a branch from
main:git checkout -b feat/my-feature # or git checkout -b fix/issue-123 -
Make your changes
- Follow coding guidelines
- Add tests
- Update documentation
-
Test your changes
cargo test cargo clippy -- -D warnings cargo fmt --check -
Commit your changes
- Follow commit message guidelines
- Make logical, atomic commits
-
Push to your fork:
git push origin feat/my-feature
-
Open a Pull Request with:
- Clear title and description
- Reference related issues
- List changes made
- Screenshots (if UI changes)
-
PR Template:
## Description Brief description of changes ## Motivation Why this change is needed ## Changes - Change 1 - Change 2 ## Testing How was this tested? ## Related Issues Fixes #123
- Maintainers will review your PR
- Address review comments
- Keep PR updated with
main - Be patient and respectful
- PR will be merged by maintainers
- Delete your branch after merge
- Celebrate your contribution! 🎉
rustun/
├── src/
│ ├── client/ # Client implementation
│ ├── server/ # Server implementation
│ ├── codec/ # Frame encoding/decoding
│ ├── crypto/ # Encryption modules
│ ├── network/ # Network abstractions
│ └── utils/ # Utilities
├── doc/ # Documentation
├── etc/ # Configuration examples
├── build.sh # Build script
└── tests/ # Integration tests
# Run all tests
cargo test
# Run specific test
cargo test test_name
# Run with output
cargo test -- --nocapture
# Run ignored tests
cargo test -- --ignored#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feature() {
// Arrange
let input = "test";
// Act
let result = my_function(input);
// Assert
assert_eq!(result, expected);
}
}- README.md - User-facing documentation
- Doc comments - API documentation
- BUILD.md - Build instructions
- CHANGELOG.md - Track changes
# Generate and open documentation
cargo doc --open
# Check documentation
cargo doc --no-deps(For maintainers only)
- Update version in
Cargo.toml - Update
CHANGELOG.md - Create release tag
- Build binaries with
./build.sh - Create GitHub Release
- Upload binaries
- GitHub Issues: Bug reports and features
- GitHub Discussions: Questions and ideas
- Documentation: Check README and docs
Contributors will be:
- Listed in release notes
- Acknowledged in CONTRIBUTORS file
- Appreciated by the community!
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Rustun! ❤️