llama_cpp_bindings/mtmd/
mtmd_error.rs1#[derive(thiserror::Error, Debug)]
3pub enum MtmdInitError {
4 #[error("Failed to create CString: {0}")]
6 CStringError(#[from] std::ffi::NulError),
7 #[error("MTMD context initialization returned null")]
9 NullResult,
10}
11
12#[derive(thiserror::Error, Debug)]
14pub enum MtmdBitmapError {
15 #[error("Failed to create CString: {0}")]
17 CStringError(#[from] std::ffi::NulError),
18 #[error("Invalid data size for bitmap")]
20 InvalidDataSize,
21 #[error("Image dimensions too small: {0}x{1} (minimum 2x2)")]
23 ImageDimensionsTooSmall(u32, u32),
24 #[error("Bitmap creation returned null")]
26 NullResult,
27}
28
29#[derive(thiserror::Error, Debug)]
31pub enum MtmdInputChunksError {
32 #[error("Input chunks creation returned null")]
34 NullResult,
35}
36
37#[derive(thiserror::Error, Debug)]
39pub enum MtmdInputChunkError {
40 #[error("Input chunk operation returned null")]
42 NullResult,
43}
44
45#[derive(thiserror::Error, Debug)]
47pub enum MtmdTokenizeError {
48 #[error("Number of bitmaps does not match number of markers")]
50 BitmapCountMismatch,
51 #[error("Image preprocessing error")]
53 ImagePreprocessingError,
54 #[error("{0}")]
56 InputChunksError(#[from] MtmdInputChunksError),
57 #[error("Failed to create CString from text: {0}")]
59 CStringError(#[from] std::ffi::NulError),
60 #[error("Unknown error: {0}")]
62 UnknownError(i32),
63}
64
65#[derive(thiserror::Error, Debug)]
67pub enum MtmdEncodeError {
68 #[error("Encode failed with code: {0}")]
70 EncodeFailure(i32),
71}
72
73use crate::mtmd::image_chunk_batch_size_mismatch::ImageChunkBatchSizeMismatch;
74
75#[derive(thiserror::Error, Debug)]
77pub enum MtmdEvalError {
78 #[error("batch size {requested} exceeds context batch size {context_max}")]
80 BatchSizeExceedsContextLimit {
81 requested: i32,
83 context_max: u32,
85 },
86 #[error(
89 "image chunk has {} tokens but n_batch is {}",
90 .0.image_tokens,
91 .0.n_batch,
92 )]
93 ImageChunkExceedsBatchSize(ImageChunkBatchSizeMismatch),
94 #[error("Eval failed with code: {0}")]
96 EvalFailure(i32),
97}