Expand description
This crate provides a library to store and load documentation content in a single file.
Content is organized into pages. The collection of pages is a book. Both pages and books can contain metadata entries.
Books
The main type in the crate is Book. A Book may contains multiple
pages and metadata entries.
Creating a New Book
New books are created with BookBuilder.
Content is added with add_metadata and
new_page.
When the book is completed, it can be persisted with
dump.
Optionally, data can be compressed with
set_compression.
Example
use theory::{MetadataEntry, Book, Page};
use std::io::{Cursor, Read, Write};
let mut buffer: Vec<u8> = Vec::new();
let mut builder = Book::builder();
builder.new_page("First").set_content("1");
builder.new_page("Second").set_content("2");
builder
.add_metadata(MetadataEntry::Title("Theory Example".into()))
.dump(Cursor::new(&mut buffer));
let book = Book::load(Cursor::new(buffer)).unwrap();
assert_eq!(book.num_pages(), 2);Loading a Book
A book written by BookBuilder::dump can be loaded with Book::load.
Crate Features
Features can be used for controlling some functionalities in the library:
-
deflateAdd supports for compressing books with DEFLATE.
-
lz4Add supports for compressing books with LZ4.
All features are enabled by default.