Skip to main content

blockworx_kernel/
handoff.rs

1//! The one channel out of the editor.
2
3use blockworx_doc::{block_model::Asset, hash::AssetHash};
4use blockworx_export::ExportContent;
5
6/// What the editor hands back, once it has something to hand back.
7///
8/// A front end sends a command in and drains this list; it never asks the
9/// editor a question. One list for every kind of result, so a result of a new
10/// kind travels the way the others already do — and so a kernel that computes
11/// one off the frame (a PDF of a large document, on a thread) can add it when
12/// the work lands without the poll on the other side changing.
13///
14/// A list rather than a slot because one frame can owe several: a document
15/// that opens on five images hands all five out at once. They are delivered
16/// in the order they were left.
17#[derive(PartialEq, serde::Serialize, serde::Deserialize)]
18pub enum Handoff {
19    /// Bytes to write out, under the name a host should suggest for them.
20    Export {
21        content: ExportContent,
22        name: String,
23    },
24    /// Text for the system clipboard.
25    Clipboard(String),
26    /// The bytes behind a hash the display list names, sent by the first
27    /// frame that paints it and never again in this session. The [`Asset`]
28    /// is the format as well as the bytes — the kernel measures and exports
29    /// by it, the front end decodes by it — so both sides read one enum.
30    Asset { hash: AssetHash, asset: Asset },
31}