Mise à jour de la configuration Rust, documentation et dépendances
Migration vers Rust 2021, ajout de la documentation en français, mise à jour des dépendances et suppression des crates inutilisées. - Mise à jour de l'édition Rust à 2021 - Ajout de commentaires de documentation en français - Suppression des dépendances `quick-xml` et `xmltree` - Ajout de nouvelles dépendances : `get_if_addrs`, `os_info`, `netstat2`, `sysinfo`, `users` - Mise à jour du fichier README.md et LICENSE - Correction de l'ordre des imports dans `src/process.rs`
This commit is contained in:
35
AGENTS.md
35
AGENTS.md
@@ -3,6 +3,9 @@
|
||||
## Build & Test Commands
|
||||
|
||||
```bash
|
||||
# Navigate to the utils directory first
|
||||
cd pmoutils
|
||||
|
||||
# Build the library
|
||||
cargo build
|
||||
|
||||
@@ -28,10 +31,11 @@ cargo fmt
|
||||
## Code Style Guidelines
|
||||
|
||||
### General
|
||||
- Rust 2024 edition
|
||||
- Rust 2021 edition
|
||||
- Follow official Rust style guide and Clippy recommendations
|
||||
- All code must be documented with Rustdoc comments
|
||||
- All code must be documented with Rustdoc comments (triple slash `///`)
|
||||
- Prefer `&str` over `String` for function parameters when possible
|
||||
- Use French documentation comments (match project convention)
|
||||
|
||||
### Imports
|
||||
- Group imports by source: std → external crates → crate modules
|
||||
@@ -42,15 +46,26 @@ cargo fmt
|
||||
- Types: `PascalCase` (e.g., `ProcessPortInfo`, `TransportProtocol`)
|
||||
- Functions/methods: `snake_case` (e.g., `guess_local_ip`, `find_process_using_port`)
|
||||
- Constants: `SCREAMING_SNAKE_CASE`
|
||||
- Traits: prefix with `To` or descriptive noun (e.g., `ToXmlElement`)
|
||||
- Tests: `test_functionality_what_it_does` format
|
||||
|
||||
### Error Handling
|
||||
- Use `Option` for operations that may not return a value (e.g., `find_process_using_port` returns `Option<ProcessPortInfo>`)
|
||||
- Use `?` operator for propagating errors
|
||||
- Use `?` operator for propagating errors from fallible functions
|
||||
- Return default values (like `"127.0.0.1"`) only when appropriate fallback exists
|
||||
- Document error conditions in function documentation
|
||||
|
||||
### Dependencies
|
||||
- `get_if_addrs`: Network interface address detection
|
||||
- `os_info`: Cross-platform OS version detection
|
||||
- `netstat2`: Network socket and process port mapping
|
||||
- `sysinfo`: Process and system information
|
||||
- `users`: User lookup by UID
|
||||
|
||||
### Platform Support
|
||||
- Currently targets Unix-like systems (macOS, Linux)
|
||||
- Socket info retrieval uses netstat2 which may have limited Windows support
|
||||
- OS detection is cross-platform via os_info crate
|
||||
|
||||
### Types
|
||||
- Prefer concrete types over generics unless abstraction is needed
|
||||
- Use `u32` for PIDs, `u16` for ports
|
||||
@@ -74,3 +89,15 @@ cargo fmt
|
||||
- Include tests for edge cases (e.g., fallback to localhost)
|
||||
- Verify return value formats and constraints
|
||||
- Test filtering: `cargo test --lib ip_utils::tests::test_list_all_ips_no_loopback`
|
||||
|
||||
### Module Organization
|
||||
- `ip_utils.rs`: Network IP address utilities (detection, listing)
|
||||
- `process.rs`: Process and port information utilities
|
||||
- Export public functions at crate root in `lib.rs`
|
||||
- Group related functionality into modules with clear responsibilities
|
||||
|
||||
### Additional Notes
|
||||
- The project uses French documentation comments throughout
|
||||
- Doctests are included and tested via `cargo test --doc`
|
||||
- Test helper functions (like `is_private_ip`) can be included in the tests module
|
||||
- Prefer explicit error handling with clear fallback behavior
|
||||
|
||||
Reference in New Issue
Block a user