use std::{ffi::CString, ptr::NonNull};
use vosk_sys::*;
pub struct BatchModel(pub(crate) NonNull<VoskBatchModel>);
impl BatchModel {
#[must_use]
pub fn new(model_path: impl Into<String>) -> Option<Self> {
let model_path_c = CString::new(model_path.into()).ok()?;
let model_ptr = unsafe { vosk_batch_model_new(model_path_c.as_ptr()) };
Some(Self(NonNull::new(model_ptr)?))
}
pub fn wait(&self) {
unsafe { vosk_batch_model_wait(self.0.as_ptr()) };
}
}
impl Drop for BatchModel {
fn drop(&mut self) {
unsafe { vosk_batch_model_free(self.0.as_ptr()) }
}
}
unsafe impl Send for BatchModel {}
unsafe impl Sync for BatchModel {}