Crate revelation_bible

Crate revelation_bible 

Source
Expand description

§revelation-bible

A comprehensive, type-safe Bible domain library for Rust applications.

This crate provides the foundational domain types and port traits for building Bible-related applications following hexagonal architecture principles. It separates domain logic from infrastructure, enabling flexible adapter implementations.

§Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Your Application                        │
├─────────────────────────────────────────────────────────────┤
│                    revelation-bible                          │
│  ┌─────────────────────┐    ┌─────────────────────────────┐ │
│  │    Domain Types     │    │       Port Traits           │ │
│  │  ─────────────────  │    │  ─────────────────────────  │ │
│  │  Book, Verse        │    │  BibleRepository            │ │
│  │  CrossReference     │◄───│  BibleSearch                │ │
│  │  SearchResult       │    │  BibleCrossReference        │ │
│  │  DailyReading       │    │  ReadingPlan                │ │
│  └─────────────────────┘    └─────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘

§Features

FeatureDescriptionDependencies
dbSQLx type derives for PostgreSQL enum mappingsqlx
apiOpenAPI schema generation for REST APIsutoipa
backendRepository port traits with error handlingmasterror

§Quick Start

use revelation_bible::{Book, Testament, Verse, VerseRef};

// Create a book reference
let genesis = Book {
    id:             1,
    name:           "Genesis".into(),
    name_ru:        "Бытие".into(),
    abbreviation:   "Gen".into(),
    testament:      Testament::Old,
    chapters_count: 50
};

// Create verse references
let single = VerseRef::single(43, 3, 16); // John 3:16
let range = VerseRef::range(45, 5, 1, 5); // Romans 5:1-5

§Domain Types

§Core Bible Structure

  • Book - Bible book with metadata (1-66 canonical books)
  • Verse - Individual verse with text content
  • ChapterInfo - Chapter metadata with verse counts
  • Testament - Old/New Testament enum

§Reading Plans

§Port Traits

When the backend feature is enabled, the following traits are available:

  • [ports::BibleRepository] - CRUD operations for Bible data
  • [ports::BibleSearch] - Full-text and symphony search
  • [ports::BibleCrossReference] - Cross-reference lookups
  • [ports::ReadingPlan] - Daily reading plan management

§Example: Implementing a Repository

use revelation_bible::ports::BibleRepository;
use revelation_bible::{Book, Verse, Testament};
use masterror::AppResult;
use sqlx::PgPool;

struct PostgresBibleRepository {
    pool: PgPool,
}

impl BibleRepository for PostgresBibleRepository {
    async fn get_books(&self) -> AppResult<Vec<Book>> {
        // Implementation using sqlx
        todo!()
    }
    // ... other methods
}

Re-exports§

pub use domain::*;

Modules§

domain
Bible domain types.