open_documentation

Function open_documentation 

Source
pub fn open_documentation(
    rect: Rectangle,
    hub: &Hub,
    context: &mut Context,
) -> Option<Reader>
Expand description

Opens the embedded documentation in a Reader view.

This helper function is shared between the app and emulator to avoid code duplication. It retrieves the embedded EPUB, creates a Reader, and returns it.

The EPUB data is accessed without copying (zero-copy). In release builds, the data is embedded as a static reference. In debug builds, the data is loaded from disk and leaked to obtain a static reference, which is acceptable since the documentation is loaded once and lives for the entire program duration.

§Arguments

  • rect - The rectangle defining the display area for the reader
  • hub - The event hub for sending update events
  • context - The application context containing display settings and fonts

§Returns

Returns Some(Reader) if the documentation was successfully opened, or None if there was an error parsing the EPUB.

§Example

use cadmus_core::assets::open_documentation;
use cadmus_core::context::Context;
use cadmus_core::view::Hub;
use cadmus_core::geom::Rectangle;
use std::sync::mpsc::channel;

// Note: In actual use, context and hub are provided by the application.
// This example shows the API pattern.
if let Some(reader) = open_documentation(rect, hub, context) {
    // Documentation opened successfully
    // The reader can be used to display the embedded EPUB
}