Skip to content

HalavicH/huh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

HUH - HalavicH's Utilities and Helpers

Welcome to HUH, a personal collection of utilities and helpers that I, HalavicH, have been crafting over time. This library is more of a "toolbelt thingy" than a cohesive library (for now). It contains a random assortment of custom code pieces that I find useful across various projects. While it may not yet form a unified framework, it has the potential to grow into something more structured in the future.

Features

  • Shared Object Utilities: Handy wrappers for Arc and tokio::sync::Mutex to simplify shared object management.
  • Error Handling Extensions: Enhancements for error_stack to improve error reporting, logging, and manipulation.
  • Pagination Utilities: Structures and helpers for managing paginated data.
  • Conflict Resolution: Tools for ensuring collections have at most one matching entity.

Why Use HUH?

Please don't (At least now) This library is not about reinventing the wheel but about collecting and refining tools that I find useful in my projects. If you're looking for a polished, production-ready library, PLEASE, RUN AWAY!. However, you might pick up few ideas on how to improve your own rust development flow.

Examples

Shared Object Utilities

I'm a fan of method chaining, and a lazy person, so I prefer to use methods to convert shared objects

use huh::{AMShared, IntoAMShared};

let shared_data: AMShared<i32> = 42.into_shared();

Error Handling Extensions

I like using error stack for nice error messages, but I didn't find a way to print the error message without a backtrace so these utils methods simply strips them

use huh::ErrorStackExt;
use error_stack::Report;

let error: Report<MyError> = some_failing_function().unwrap_err();
println!("Error without backtrace: {}", error.to_string_no_bt());

Pagination

I'm sure there's better lib for this somewhere, but it was quicker to write it manually

use huh::Pagination;

let default_pagination = Pagination::default();
println!("Default pagination: {:?}", default_pagination);

Conflict Resolution

Don't have a better name for it, but it basically returns Ok if vec contains zero or one item, and error if more (ensures uniqueness)

use huh::maybe_extract_item;

let items = vec![1, 2];
let result = maybe_extract_item(items, "key");

Installation

Add the following to your Cargo.toml:

[dependencies]
huh = "0.1.0"

Contributing

This library is a personal project, but contributions are welcome! If you see that I misused some lib i wrote an extention for, and reivented existing functionality - feel free to point it out. Code contributions are also welcomed

License

This project is licensed under the MIT License. file for details.

About

HalavicH's Utilities and Helpers (Rust)

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE.md
Apache-2.0
LICENSE-APACHE.md
MIT
LICENSE-MIT.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages