Struct crowbook::BookOptions [] [src]

pub struct BookOptions {
    pub root: PathBuf,
    // some fields omitted
}

Contains the options of a book.

Fields

Root path of the book (unnecessary copy :/)

Methods

impl BookOptions
[src]

Creates a new BookOptions struct from the default compliled string

Sets an option from a Yaml tuple

Arguments

  • key: the identifier of the option, must be Yaml::String(_)
  • value: the value of the option

Returns an error if key is not a String, not a valid option, of if the value is not of the right type.

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(&[]);
book.options.set("author", "Joan Doe").unwrap(); // ok
book.options.set("numbering", "2").unwrap(); // sets numbering to chapters and subsections
let result = book.options.set("autor", "John Smith"); 
assert!(result.is_err()); // error: "author" was mispelled "autor"

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

Gets an option

Gets a list of path. Only used for resources.files.

Gets a string option

Get a path option

Adds book's root path 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

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.