#[derive(thiserror::Error, Debug)]
pub enum MtmdInitError {
#[error("Failed to create CString: {0}")]
CStringError(#[from] std::ffi::NulError),
#[error("MTMD context initialization returned null")]
NullResult,
}
#[derive(thiserror::Error, Debug)]
pub enum MtmdBitmapError {
#[error("Failed to create CString: {0}")]
CStringError(#[from] std::ffi::NulError),
#[error("Invalid data size for bitmap")]
InvalidDataSize,
#[error("Image dimensions too small: {0}x{1} (minimum 2x2)")]
ImageDimensionsTooSmall(u32, u32),
#[error("Bitmap creation returned null")]
NullResult,
}
#[derive(thiserror::Error, Debug)]
pub enum MtmdInputChunksError {
#[error("Input chunks creation returned null")]
NullResult,
}
#[derive(thiserror::Error, Debug)]
pub enum MtmdInputChunkError {
#[error("Input chunk operation returned null")]
NullResult,
}
#[derive(thiserror::Error, Debug)]
pub enum MtmdTokenizeError {
#[error("Number of bitmaps does not match number of markers")]
BitmapCountMismatch,
#[error("Image preprocessing error")]
ImagePreprocessingError,
#[error("{0}")]
InputChunksError(#[from] MtmdInputChunksError),
#[error("Failed to create CString from text: {0}")]
CStringError(#[from] std::ffi::NulError),
#[error("Unknown error: {0}")]
UnknownError(i32),
}
#[derive(thiserror::Error, Debug)]
pub enum MtmdEncodeError {
#[error("Encode failed with code: {0}")]
EncodeFailure(i32),
}
use crate::mtmd::image_chunk_batch_size_mismatch::ImageChunkBatchSizeMismatch;
#[derive(thiserror::Error, Debug)]
pub enum MtmdEvalError {
#[error("batch size {requested} exceeds context batch size {context_max}")]
BatchSizeExceedsContextLimit {
requested: i32,
context_max: u32,
},
#[error(
"image chunk has {} tokens but n_batch is {}",
.0.image_tokens,
.0.n_batch,
)]
ImageChunkExceedsBatchSize(ImageChunkBatchSizeMismatch),
#[error("Eval failed with code: {0}")]
EvalFailure(i32),
}