Skip to content

jkaraskiewicz/commons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

[dependencies]
commons = "0.2.6"

Then, you can use the utilities in your code:

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.

About

Small private common library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages