Skip to main content

Event

Enum Event 

Source
pub enum Event {
    InferDone {
        text: String,
        tokens_out: u32,
    },
    Opened {
        handle: Handle,
        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: Handle,
        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

§text: String

The generated text.

§tokens_out: u32

How many tokens were produced. May be fewer than the requested max_tokens if the guest ended generation early.

§

Opened

A file was opened.

Fields

§handle: Handle

Use this in subsequent Command::Slice calls.

§len: u64

Total size of the file, in bytes.

§kind: MediaKind

What the host made of the contents; see MediaKind.

#[serde(default)] so a block built before this field existed still deserializes, treating anything it opens as text.

§

Sliced

A window of a file was read.

Fields

§text: String

The window’s contents.

§next_offset: u64

Where 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: String

The 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: u64

Where 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.

Fields

§vectors: Vec<Vec<f32>>

The vectors, each the model’s full dimensionality.

§

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.

Fields

§text: String

The page’s text.

§

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

§text: Option<String>

The page’s text, when it could be extracted.

§error: Option<String>

Why it could not, otherwise — verbatim, so a caller can record it per item rather than reporting “extraction failed”.

§

PageImaged

A document page was rendered to an image.

Fields

§handle: Handle

A new handle referring to the rendered image; name it in Command::Infer.

§len: u64

Its size in bytes.

§

Emitted

Progress was forwarded. Carries nothing; it exists so Emit has a reply and the command loop keeps its shape.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

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 Event

Source§

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

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

impl<'de> Deserialize<'de> for Event

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 Event

Source§

fn eq(&self, other: &Event) -> 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 Event

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 Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

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>,

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
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.