Thank you for your interest in contributing! This document provides guidelines for contributing to the project.
- Rust 1.70 or later
- Cargo
- Git
-
Fork the repository
-
Clone your fork:
git clone https://github.com/yourusername/p2p-transfer.git cd p2p-transfer -
Build the project:
cargo build
-
Run tests:
cargo test
p2p-transfer/
├── src/ # Main binary entry point
├── p2p-core/ # Core library
│ └── src/
│ ├── protocol.rs # Message definitions
│ ├── network/ # Networking layer
│ ├── compression.rs # Compression utilities
│ ├── verification.rs # Checksums
│ ├── transfer.rs # Transfer logic
│ └── ...
├── p2p-cli/ # CLI interface
│ └── src/
│ └── lib.rs
├── p2p-gui/ # GUI interface
│ └── src/
│ └── lib.rs
└── docs/ # Documentation
- Follow Rust standard formatting (
cargo fmt) - Use
cargo clippyto catch common mistakes - Write idiomatic Rust code
- Add documentation comments for public APIs
snake_casefor functions, variables, modulesPascalCasefor types, traits, enumsSCREAMING_SNAKE_CASEfor constants- Use descriptive names
- Use the
Resulttype for operations that can fail - Use custom error types from
error.rs - Provide context with error messages
- Don't panic in library code
- Write unit tests for all modules
- Write integration tests for features
- Use
#[cfg(test)]modules for unit tests - Aim for high test coverage
- Add doc comments (
///) for public items - Include examples in doc comments
- Update README.md for user-facing changes
- Update DESIGN.md for architectural changes
main- stable releasesdevelop- development branchfeature/*- new featuresbugfix/*- bug fixeshotfix/*- urgent fixes
-
Create a branch:
git checkout -b feature/your-feature-name
-
Make your changes
-
Format and lint:
cargo fmt cargo clippy -- -D warnings
-
Run tests:
cargo test -
Commit with clear messages:
git commit -m "feat: add UDP discovery implementation"
Follow conventional commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Test changesrefactor:- Code refactoringperf:- Performance improvementschore:- Maintenance tasks
-
Push your branch:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub
-
Fill out the PR template
-
Link related issues
-
Wait for review
- Be respectful and constructive
- Explain reasoning for changes
- Address all feedback
- Keep discussions focused
# All tests
cargo test
# Specific test
cargo test test_name
# With output
cargo test -- --nocapture
# Integration tests only
cargo test --test '*'#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_something() {
// Arrange
let input = 42;
// Act
let result = function_under_test(input);
// Assert
assert_eq!(result, expected);
}
}# CPU profiling
cargo flamegraph --bin p2p-transfer
# Memory profiling
cargo instruments -t Allocationscargo benchcargo doc --open/// Brief description.
///
/// Longer description with details.
///
/// # Examples
///
/// ```
/// use p2p_core::example;
/// let result = example::function();
/// assert_eq!(result, expected);
/// ```
///
/// # Errors
///
/// Returns an error if...
///
/// # Panics
///
/// Panics if...
pub fn function() -> Result<()> {
// ...
}- Update version in
Cargo.toml - Update
CHANGELOG.md - Create a tag:
git tag v0.1.0 - Push tag:
git push origin v0.1.0 - Create GitHub release
- Publish to crates.io:
cargo publish
- Open an issue for bugs
- Start a discussion for questions
- Join our chat (TBD)
- Check existing issues and PRs
By contributing, you agree that your contributions will be licensed under the MIT License.
We pledge to make participation in our project a harassment-free experience for everyone.
- Be respectful and inclusive
- Accept constructive criticism
- Focus on what's best for the community
- Show empathy
Report issues to the maintainers. All complaints will be reviewed and investigated.
Thank you for contributing! 🎉