Struct crowbook::BookOptions [] [src]

pub struct BookOptions { /* fields omitted */ }

Contains the options of a book.

Methods

impl BookOptions
[src]

Creates a new BookOptions struct from the default compliled string

Sets an option

Arguments

  • key: the identifier of the option, e.g.: "author"
  • value: the value of the option as a string

Returns

  • an error either if key is not a valid option or if the value is not of the right type.
  • an option containing None if key was not set, and Some(previous_value) if key was already present.

Examples

use crowbook::Book;
let mut book = Book::new(&[]);
// Set author
book.options.set("author", "Joan Doe").unwrap();
// Set numbering to chapters and subsections
book.options.set("rendering.num_depth", "2").unwrap();
// Try to set invalid key "autor"
let result = book.options.set("autor", "John Smith");
assert!(result.is_err()); // error: "author" was mispelled "autor"

let result = book.options.set("rendering.num_depth", "foo");
assert!(result.is_err()); // error: numbering must be an intRun

Gets a string option

Get a path option

Adds the correct path correction before it

Get a path option

Don't add book's root path before it

gets a bool option

gets a char option

gets an int option

gets a float option

Returns a description of all options valid to pass to a book.

arguments

  • md: whether the output should be formatted in Markdown

Trait Implementations

impl Debug for BookOptions
[src]

Formats the value using the given formatter.