https://github.com/jkaraskiewicz/commons
Small private common library
https://github.com/jkaraskiewicz/commons
common std stdlib
Last synced: 5 months ago
JSON representation
Small private common library
- Host: GitHub
- URL: https://github.com/jkaraskiewicz/commons
- Owner: jkaraskiewicz
- Created: 2025-03-14T18:17:28.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-04-14T22:18:02.000Z (10 months ago)
- Last Synced: 2025-06-11T10:46:34.295Z (8 months ago)
- Topics: common, std, stdlib
- Language: Rust
- Homepage:
- Size: 40 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Commons
A collection of reusable utilities for Rust projects.
## Features
This library provides a set of modules to simplify common tasks in Rust applications.
### Traits
- **`collections`**: Extends collections with `contains`, `contains_predicate`, and `first` methods.
- **`result`**: Adds a `to_result` method to `bool` for easy conversion to a `Result`.
### Types
- **`errors`**: Defines a common `CommonsError` enum for handling I/O and environment variable errors.
### Utils
- **`datetime_util`**: Functions for working with dates and times, including getting the current date, timestamp, and formatting `SystemTime`.
- **`file_util`**: Utilities for reading, writing, deleting, and copying files and directories.
- **`hash_util`**: Functions for generating SHA256 hashes for strings and files, and for creating unique IDs.
- **`path_util`**: Utilities for expanding the home directory (`~`) in paths and getting the home directory path.
- **`shell_util`**: Functions for executing shell commands.
- **`string_util`**: A utility for finding the minimum unique prefix of a string within a list of strings.
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
commons = "0.2.6"
```
Then, you can use the utilities in your code:
```rust
use commons::utils::file_util;
fn main() {
let content = file_util::read_file("path/to/your/file.txt").unwrap();
println!("{}", content);
}
```
## Contributing
Contributions are welcome! Please feel free to submit a pull request.
## License
This project is licensed under the MIT License.