Crate bibleref

Crate bibleref 

Source
Expand description

§A Rust Crate for managing Bible references, books, chapters and verses

Bibleref is a lightweight Rust crate which supports the management of Bible references including parsing, validity checks and output. It is designed to simplify the usage of God’s infallible and Holy Word for computing purposes with the aim to simplify the spreading of the good news. May it be used for the glory of God!

§Features

  • Provides internal structures for Bible reference representations (single and ranging) consisting of books, chapters and/or verses
  • Parses Bible references from real world languages
  • Translates internal Bible references into real world languages
  • Translates Bible references from one language to another
  • Validates Bible references
  • Gets the number of chapters and verses of a Bible book
  • Upcast/downcast Bible references to/from different types
  • Iterating over Bible references (e.g all books of the Bible, all chapters of a book, all verses of a chapter)

§Examples

§Does Genesis 4:5 exist?

// Genesis 4:5 exists and is a valid Bible reference (of type BibleVerse)
assert!(bibleref::parse("Genesis 4:5").is_ok());

§How about 出埃及记2:3 (Exodus 2:3 in Chinese)?

// 出埃及记2:3 exists and is a valid Bible reference (of type BibleVerse)
assert!(bibleref::parse("出埃及记2:3").is_ok());

§Translate “John 3:16-18” into German

// The German translation of John 3:16-18 is "Johannes 3,16-18"
let german_reference: String = bibleref::translate("John 3:16-18", "de").unwrap();
assert_eq!(german_reference, "Johannes 3,16-18");

§Get the number of chapters in the book of Revelation

use bibleref::bible::validate::get_number_of_chapters;
use bibleref::bible::BibleBook;
// The book of Revelation has 22 chapters
assert_eq!(get_number_of_chapters(&BibleBook::Revelation), 22);
use bibleref::bible::{BibleReference, BibleBook, BibleBookReference};
use bibleref::referencing::language::{get_reference_in_language, BookReferenceType};
BibleBook::all().iter().for_each(|book| {
    println!("English: {}, German: {}", 
        get_reference_in_language(
            &BibleReference::BibleBook(BibleBookReference::new(*book)),
            "en",
            BookReferenceType::Long,
        ).unwrap(),
        get_reference_in_language(
            &BibleReference::BibleBook(BibleBookReference::new(*book)),
            "de",
            BookReferenceType::Long,
        ).unwrap()
    );
});

Modules§

bible
The Bible module includes the data structure around a Bible, including books, chapters and verses. It also handles the parsing process which determins the validity of Bible references.
errors
The crate contains several error types that are used to represent errors that occur when working with Bible references.
referencing
This module contains structures and functions for representing and understanding Bible references in human understandable language.

Functions§

parse
Parses a given bible reference with all supported languages and returns an Result<BibleReference, Box<dyn Error>> depending on whether the parsing was successful.
translate
Translates a Bible reference in an other language