An open API service indexing awesome lists of open source software.

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

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.