pub mod array;
pub mod error;
pub mod generate;
pub mod media;
pub mod models;
pub(crate) mod mtp_certification;
pub mod nn;
pub mod ops;
pub mod prompt_cache;
pub mod quant;
pub mod reasoning;
pub mod sampling;
pub mod parity;
pub(crate) mod spec;
pub mod stream;
pub mod streaming;
pub(crate) mod sys;
#[cfg(test)]
pub mod test_support;
pub mod tokenizer;
pub mod tools;
pub mod weights;
pub use error::{Error, Result};
#[derive(Clone, Copy)]
pub(crate) struct Cancellation<'a>(Option<&'a dyn Fn() -> bool>);
impl<'a> Cancellation<'a> {
pub(crate) const fn disabled() -> Self {
Self(None)
}
pub(crate) const fn cooperative(predicate: &'a dyn Fn() -> bool) -> Self {
Self(Some(predicate))
}
pub(crate) const fn is_cooperative(self) -> bool {
self.0.is_some()
}
pub(crate) fn checkpoint(self) -> Result<()> {
if self.0.is_some_and(|predicate| predicate()) {
return Err(Error::Cancelled);
}
Ok(())
}
}