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.
- Shared Object Utilities: Handy wrappers for
Arcandtokio::sync::Mutexto simplify shared object management. - Error Handling Extensions: Enhancements for
error_stackto 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.
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.
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();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());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);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");Add the following to your Cargo.toml:
[dependencies]
huh = "0.1.0"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
This project is licensed under the MIT License. file for details.