Crates.io | bible-io |
lib.rs | bible-io |
version | 1.0.1 |
created_at | 2025-08-27 08:16:59.584223+00 |
updated_at | 2025-09-23 07:37:23.166153+00 |
description | A Rust library for working with Bible text data structures |
homepage | |
repository | https://github.com/m0ty/bible-json-package-rs |
max_upload_size | |
id | 1812296 |
size | 5,029,664 |
A Rust library for working with Bible text data structures, providing efficient parsing and access to Bible books, chapters, and verses.
Add this to your Cargo.toml
:
[dependencies]
bible-io = "1.0.0"
Basic usage:
use rust_bible_struct::{Bible, BibleBook};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let bible = Bible::new_from_json("path/to/bible.json")?;
// Get a specific verse
if let Ok(verse) = bible.get_verse(BibleBook::Genesis, 1, 1) {
println!("{}", verse);
}
// Get all verses from a chapter
if let Ok(verses) = bible.get_verses(BibleBook::Psalms, 23) {
for verse in verses {
println!("{}", verse);
}
}
Ok(())
}
The library expects Bible data in the following JSON format:
{
"id": "kjv",
"name": "King James Version",
"description": "The King James Version (Oxford 1769) is a standardized revision of the classic 1611 English Bible.",
"language": "English",
"books": {
"gn": {
"name": "Genesis",
"chapters": {
"1": {
"1": "In the beginning God created the heaven and the earth.",
"2": "And the earth was without form, and void; and darkness {was} upon the face of the deep. And the Spirit of God moved upon the face of the waters.",
"3": "And God said, Let there be light: and there was light."
},
"2": {
"1": "Thus the heavens and the earth were finished, and all the host of them.",
"2": "And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.",
"3": "And God blessed the seventh day, and sanctified it: because that in it he had rested from all his work which God created and made. "
}
}
}
}
}
Top-level fields identify the translation. Each entry in books
uses a book abbreviation (e.g., "gn"
) and contains a name
and a chapters
array, where each chapter is a list of verse strings.
Run the included example:
cargo run --example basic_usage
# Run all tests (requires en_kjv.json)
cargo test
# Run only unit tests (no external data required)
cargo test --lib
# Run only integration tests
cargo test --test integration_tests
MIT License - see LICENSE file for details.