Skip to main content

Book

Struct Book 

Source
pub struct Book {
    pub metadata: Metadata,
    pub sections: Vec<Section>,
}
Expand description

The root of the content tree: one book.

Fields§

§metadata: Metadata

The work’s title, author and frontend extensions.

§sections: Vec<Section>

The chapters/files, in reading order.

Implementations§

Source§

impl Book

Source

pub fn anchors(&self) -> Anchors

What the links in this book can reach.

Read it after Book::assign_node_ids, because the nodes it gives are the ids that numbering assigns.

Source§

impl Book

Source

pub fn assign_node_ids(&mut self)

Assign ids to every node, in document order (pre-order: a node before its children, sections in reading order), starting at 1. Runs once, after deserialization; running it again renumbers.

Source

pub fn node_at(&self, source: &str, byte: u32) -> Option<NodeId>

The node one byte of one source was read into: the innermost, so a byte of prose answers with the run it was typed into and a byte of markup answers with the construct it opens.

Only sections read from that source are looked at, so one file’s cursor is answered by one file’s nodes. Nothing for a byte no node was read from, such as a blank line between chapters or a source’s frontmatter, and nothing for a tree built rather than parsed.

Source

pub fn source_of(&self, node: NodeId) -> Option<(&str, SourceSpan)>

The source a node was read from, and the bytes of it the node covers.

Nothing for a node the engine synthesized, or one from a tree built rather than parsed: neither was read from anything.

Source

pub fn names(&self, source: Option<&str>) -> Names

The classes and the ids the blocks and inlines of one source carry, or of every source when source is None. A list item, a table row or cell, and a note count as blocks and inlines here.

A section’s own names are not in the answer. A host sets them beside the source, or frontmatter writes them.

Source

pub fn subtree(&self, node: NodeId) -> Option<Range<u32>>

The ids one node and its descendants hold.

Ids are assigned in document order, a node before its children, so what a node covers is a run of consecutive numbers. Asking what a node was set from is asking about every id in this range.

Nothing for a node the book does not hold.

Trait Implementations§

Source§

impl Clone for Book

Source§

fn clone(&self) -> Book

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Book

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Book

Source§

fn default() -> Book

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Book

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Book

Source§

fn eq(&self, other: &Book) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Book

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Book

Auto Trait Implementations§

§

impl Freeze for Book

§

impl RefUnwindSafe for Book

§

impl Send for Book

§

impl Sync for Book

§

impl Unpin for Book

§

impl UnsafeUnpin for Book

§

impl UnwindSafe for Book

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.