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
impl Bible
Sourcepub fn new(translation: Translation) -> Result<Self, BibleLibError>
pub fn new(translation: Translation) -> Result<Self, BibleLibError>
Create a new Bible instance with the specified translation
Sourcepub fn get_translation(&self) -> &Translation
pub fn get_translation(&self) -> &Translation
Get the current translation of the Bible instance
Sourcepub fn get_verse(
&self,
lookup: BibleLookup,
use_superscripts: bool,
) -> Result<String, BibleLibError>
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);Sourcepub fn get_chapter(
&self,
book: &str,
chapter: u32,
use_superscripts: bool,
) -> Result<String, BibleLibError>
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::EnglishedRevised).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);Sourcepub fn get_books(&self) -> Vec<String>
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);Sourcepub fn get_chapters(&self, book: &str) -> Result<Vec<u32>, BibleLibError>
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);Sourcepub fn get_verses(
&self,
book: &str,
chapter: u32,
) -> Result<Vec<u32>, BibleLibError>
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);Sourcepub fn get_max_verse(
&self,
book: &str,
chapter: u32,
) -> Result<u32, BibleLibError>
pub fn get_max_verse( &self, book: &str, chapter: u32, ) -> Result<u32, BibleLibError>
Get the maximum verse number in a chapter of a book
Sourcepub fn random_verse(&self) -> BibleLookup
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more