Skip to main content

rok_utils/
lib.rs

1//! rok-utils — Laravel/AdonisJS-inspired utility helpers for Rust.
2
3pub mod arr;
4pub mod data;
5pub mod errors;
6pub mod fp;
7pub mod fs;
8pub mod path;
9pub mod result;
10pub mod str;
11pub mod string;
12pub mod types;
13
14pub use arr::*;
15pub use data::numbers;
16pub use errors::ResultExt as RokResultExt;
17pub use errors::{ResultExt, RokError};
18pub use fp::{apply, compose, memoize, or_default, pipe, retry, tap, Lazy};
19pub use fs::{
20    copy_dir_all, ensure_dir, find_files, is_dir, is_file, read_bytes, read_to_string, write_atomic,
21};
22pub use path::{normalize, stem_ext, with_extension};
23pub use str::{to_base64, Str};
24pub use string::{
25    char_at, contains, contains_all, doesnt_contain, ends_with, ensure_start, finish, invert_case,
26    is_alphanumeric, is_ascii, is_empty, is_url, lcfirst, length, mask, pad_both, pad_left,
27    pad_right, pluralize, position, pretty_duration, repeat, replace_first, replace_last, reverse,
28    slug, squish, starts_with, substr_count, to_camel_case, to_dot_case, to_headline,
29    to_kebab_case, to_lower, to_no_case, to_pascal_case, to_screaming_snake, to_sentence_case,
30    to_snake_case, to_title_case, to_upper, truncate, ucfirst, unwrap, word_count, wrap,
31};
32
33#[cfg(feature = "dates")]
34pub use data::{
35    add_days, add_hours, diff_days, format_date, human_diff, now, parse_date, today, tomorrow,
36    yesterday,
37};
38
39#[cfg(feature = "crypto")]
40pub use data::{generate_token, hash_sha256, secure_compare, verify_sha256};
41
42#[cfg(feature = "ids")]
43pub use data::{is_ulid, is_uuid, ulid, uuid_v4, uuid_v7};
44
45#[cfg(feature = "random")]
46pub use string::{password, random};
47
48#[cfg(feature = "json")]
49pub use str::escape_html;
50
51#[cfg(feature = "json")]
52pub use string::is_json;
53
54#[cfg(feature = "json")]
55pub use types::{
56    deep_equal, get_path, is_array, is_bool, is_null, is_number, is_object, is_string, set_path,
57};
58
59#[cfg(feature = "random")]
60pub use fp::shuffle;
61
62#[cfg(test)]
63mod tests {
64    #[test]
65    fn it_works() {
66        assert!(true);
67    }
68}