pub enum Event {
InferDone {
text: String,
tokens_out: u32,
},
Opened {
handle: u32,
len: u64,
kind: MediaKind,
},
Sliced {
text: String,
next_offset: u64,
},
SlicedBytes {
bytes_base64: String,
next_offset: u64,
},
Embedded {
vectors: Vec<Vec<f32>>,
},
PageTexted {
text: String,
},
PageTextAttempted {
text: Option<String>,
error: Option<String>,
},
PageImaged {
handle: u32,
len: u64,
},
Emitted,
}Expand description
What the host feeds back into the guest’s step export after carrying out a
Command.
Variants§
InferDone
Generation finished.
Fields
Opened
A file was opened.
Fields
handle: u32Use this in subsequent Command::Slice calls.
Sliced
A window of a file was read.
Fields
next_offset: u64Where the returned text actually ended.
This is not always offset + len from the request: the host cuts
a window back to a UTF-8 character boundary, because a caller picking
window sizes has no idea where characters begin, and a naive split
would corrupt a multi-byte character at nearly every seam. A guest
walking a file must resume from this value rather than advancing by
the length it asked for.
SlicedBytes
A window of a file was read as raw bytes.
Fields
bytes_base64: StringThe window’s contents, base64-encoded.
Base64 rather than a binary side channel: the boundary is JSON, and keeping it inspectable is worth more than the third it costs on a path blocks are not expected to use in bulk.
next_offset: u64Where the returned bytes ended. Unlike Event::Sliced there is no
truncation, so this is always offset + len clamped to the file.
Embedded
One vector per text handed to Command::Embed, in the same order.
PageTexted
Text extracted from a document — one page, or the whole thing.
Shared by Command::PageText and Command::DocumentText: both
answer with text and nothing else, so a second variant carrying an
identical payload would add surface without adding information. The
command is what names the intent.
PageTextAttempted
The outcome of a Command::PageTextOpt.
Exactly one of text and error is set. A separate event from
Event::PageTexted because the payloads genuinely differ: this one
can carry a reason, and folding them together would mean every caller
of the ordinary command handling an error arm that cannot occur.
Fields
PageImaged
A document page was rendered to an image.
Fields
handle: u32A new handle referring to the rendered image; name it in
Command::Infer.
Emitted
Progress was forwarded. Carries nothing; it exists so Emit has a reply
and the command loop keeps its shape.