Bible

Struct Bible 

Source
pub struct Bible {
    pub verses: HashMap<String, HashMap<u32, HashMap<u32, String>>>,
    /* private fields */
}
Expand description

Main Bible struct Stores the verses of the Bible for interfacing

§Example

use bible_lib::{Bible, Translation, BibleLookup};

// get the bible translation
let bible = Bible::new(Translation::AmericanStandard).unwrap();

// create a lookup for John 3:16
let lookup = BibleLookup::new("John", 3, 16);
// get the verse text
let verse = bible.get_verse(lookup, false).unwrap();

// print the verse text
println!("John 3:16: {}", verse);

Fields§

§verses: HashMap<String, HashMap<u32, HashMap<u32, String>>>

Implementations§

Source§

impl Bible

Source

pub fn new(translation: Translation) -> Result<Self, BibleLibError>

Create a new Bible instance with the specified translation

Source

pub fn get_translation(&self) -> &Translation

Get the current translation of the Bible instance

Source

pub fn get_verse( &self, lookup: BibleLookup, use_superscripts: bool, ) -> Result<String, BibleLibError>

Get the text of a verse or range of verses use_superscripts adds superscript verse numbers for better readability Returns an error if the verse or chapter is not found

§Example
use bible_lib::{Bible, BibleLookup, Translation};

// get the bible translation
let bible = Bible::new(Translation::AmericanStandard).unwrap();
// create a lookup for John 3:16
let lookup = BibleLookup::new("John", 3, 16);
// get the verse text
let verse = bible.get_verse(lookup, false).unwrap();

// print the verse text
println!("John 3:16: {}", verse);
Source

pub fn get_chapter( &self, book: &str, chapter: u32, use_superscripts: bool, ) -> Result<String, BibleLibError>

Get the text of an entire chapter as a string use_superscripts adds superscript verse numbers for better readability Returns an error if the chapter is not found

§Example
use bible_lib::{Bible, BibleLookup, Translation};

// get the bible translation
let bible = Bible::new(Translation::EnglishRevised).unwrap();
// get the text of Isaiah chapter 53
let chapter_text = bible.get_chapter("Isaiah", 53, true).unwrap();

// print the chapter text
println!("Isaiah 53: {}", chapter_text);
Source

pub fn get_books(&self) -> Vec<String>

Get a list of all books in the Bible

§Example
use bible_lib::{Bible, Translation};

// get the bible translation
let bible = Bible::new(Translation::default()).unwrap();

// get the list of books
let books = bible.get_books();
// print the list of books
println!("Books in the Bible: {:?}", books);
Source

pub fn get_sorted_books(&self) -> Vec<String>

Get a list of all books in the Bible, sorted in canonical order

§Example
use bible_lib::{Bible, Translation};

// get the bible translation
let bible = Bible::new(Translation::default()).unwrap();

// get the list of books
let books = bible.get_sorted_books();
// print the list of books
println!("Books in the Bible: {:?}", books);
Source

pub fn get_chapters(&self, book: &str) -> Result<Vec<u32>, BibleLibError>

Get a list of all chapters in a book

§Example
use bible_lib::{Bible, Translation};

// get the bible translation
let bible = Bible::new(Translation::default()).unwrap();

// get the list of chapters in Revelation
let chapters = bible.get_chapters("Revelation").unwrap();
// print the list of chapters
println!("Chapters in Revelation: {:?}", chapters);
Source

pub fn get_verses( &self, book: &str, chapter: u32, ) -> Result<Vec<u32>, BibleLibError>

Get a list of all verses in a chapter of a book

§Example
use bible_lib::{Bible, Translation};

// get the bible translation
let bible = Bible::new(Translation::default()).unwrap();

// get the list of verses in John chapter 3
let verses = bible.get_verses("John", 3).unwrap();
// print the list of verses
println!("Verses in John 3: {:?}", verses);
Source

pub fn get_max_verse( &self, book: &str, chapter: u32, ) -> Result<u32, BibleLibError>

Get the maximum verse number in a chapter of a book

Source

pub fn get_max_chapter(&self, book: &str) -> Result<u32, BibleLibError>

Get the maximum chapter number in a chapter of a book

Source

pub fn random_verse(&self) -> BibleLookup

Get a random verse from the Bible Requires the random feature to be enabled

§Example
use bible_lib::{Bible, Translation};

// get the bible translation
let bible = Bible::new(Translation::default()).unwrap();

// get a random verse
let random_verse = bible.random_verse();
// get the verse text
let verse_text = bible.get_verse(random_verse.clone(), false).unwrap();
// print the random verse
println!("Random Verse: {} - {}", random_verse, verse_text);

Trait Implementations§

Source§

impl Clone for Bible

Source§

fn clone(&self) -> Bible

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Bible

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Bible

§

impl RefUnwindSafe for Bible

§

impl Send for Bible

§

impl Sync for Bible

§

impl Unpin for Bible

§

impl UnwindSafe for Bible

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V