Struct bookfile::Book[][src]

pub struct Book<R> { /* fields omitted */ }
Expand description

An interface for reading a Bookfile.

The Book type represents a read-only Bookfile. Invividual chapters can be read in their entirety, or incrementally using the Read interface. Seek and read_at/read_exact_at are also provided, and work within the context of that chapter: the seek offset is the offset within the chapter, and a read at the end of the chapter will return EOF.

Implementations

Return the file’s magic number.

Each BookWriter specifies a magic number, used to identify this file format. This method returns the value found in the file.

Create a shared reader object.

This returns a BoundedReader that does not implement Seek or Read, only read_at and read_exact_at This means it can be used via a shared reference.

If the Seek and Read traits are required, use exclusive_chapter_reader instead.

Read all bytes in a chapter.

This is the same thing as calling chapter_reader followed by read_exact_at.

Create a new Book from a stream.

This call will attempt to read the file header and table of contents. It may fail due to IO errors while reading, or invalid file data.

The stream must impl the Read and Seek traits (e.g. a File).

Check whether a chapter exists.

For now, we assume chapter ids are unique. That’s dumb, and will be fixed in a future version.

Read a chapter, with seeking.

This returns a BoundedReader that can read and seek within the chapter (assuming the underlying Book implements Read + Seek). The Seek and Read traits require exclusive access. For a shared reader, use chapter_reader instead.

Read all bytes in a chapter.

This is the same thing as calling exclusive_chapter_reader followed by read_to_end. It can be used on anything that implements Read + Seek, but as a result it requires exclusive access via a mutable reference.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.