pub struct MtmdLazyBitmap { /* private fields */ }Expand description
A bitmap whose contents are produced on demand, during tokenization.
An ordinary MtmdBitmap holds decoded pixels or samples from the moment
it is built. This holds a callback instead, invoked with 0, 1, 2, … while
the prompt is tokenized and expanding into however many chunks it yields.
That matters for two cases:
- a long video, where materialising every frame up front would not fit in memory;
- media that may never be reached, because a stop sequence or a token budget cuts the prompt short first.
The callback must outlive tokenization, so this owns it alongside the bitmap and drops them in that order.
Wraps mtmd_bitmap_init_lazy.
Implementations§
Source§impl MtmdLazyBitmap
impl MtmdLazyBitmap
Sourcepub fn new<F>(ctx: &MtmdContext, id: &str, callback: F) -> Result<Self>
pub fn new<F>(ctx: &MtmdContext, id: &str, callback: F) -> Result<Self>
Build a lazy bitmap identified by id (conventionally a file hash).
callback is called with increasing chunk indices until it returns
MtmdLazyChunk::End.
§Errors
Returns MtmdError::BitmapCreateFailed if llama.cpp returns null, or
MtmdError::InvalidPath if id contains an interior NUL.
Sourcepub fn as_bitmap(&self) -> &MtmdBitmap
pub fn as_bitmap(&self) -> &MtmdBitmap
Borrow this as an ordinary bitmap, for passing to
MtmdContext::tokenize.