Crate gematria_rs
source ·Expand description
Gematria-rs Library API
This module provides an implementation of the Gematria, a traditional Hebrew numerology system. It supports various methods such as Mispar Hechrechi, Mispar Gadol, Mispar Katan, and Otiyot BeMilui.
The core functionality is encapsulated in the GematriaContext struct, which offers methods to
calculate gematria values for Hebrew characters and words. It supports optional caching for improved
performance and can be configured to preserve or remove Hebrew vowels in the calculations.
GematriaBuilder facilitates a flexible construction of GematriaContext with various configuration options.
Example usage:
use gematria_rs::{GematriaBuilder, GematriaMethod};
let gmctx = GematriaBuilder::new()
.with_method(GematriaMethod::MisparHechrechi)
.with_cache(true)
.with_vowels(true)
.init_gematria();
let hello = "שָׁלוֹם";
let res_1 = gmctx.calculate_value(hello);
println!("Gematria value: {}", res_1.value());
// The word original vowels preserved on the result
let hello_without_vowels = "שלום";
let res_2 = gmctx.calculate_value(hello_without_vowels);
assert_eq!(res_1.word(), hello);
assert_ne!(res_1.word(), hello_without_vowels);
assert_eq!(res_1.value(), res_2.value());Author: Amit Shmulevitch
Structs
GematriaBuilderprovides a builder pattern for constructingGematriaContext. It allows specifying the gematria calculation method, whether to enable caching, and vowel preservation. Example usage:GematriaContextholds the core logic for gematria calculations. It encapsulates the mapping of Hebrew characters to their numeric values and the chosen calculation strategy. Optionally, it can cache calculated values for improved performance and handle vowel preservation in input words.GematriaResultrepresents the result of a gematria calculation, including the calculated value, the method used, and the original word.HebrewCharacterMapmaps Hebrew characters to their corresponding numeric indices.
Enums
- Enumerates various gematria calculation methods. Includes traditional and specialized methods like Mispar Hechrechi and Otiyot BeMilui.
Traits
- A trait defining the common functionality for gematria calculations.
Functions
- Calculates the standard gematria value for a given Hebrew letter based on its index.