Initial commit

This commit is contained in:
0/0 2022-10-09 20:17:31 -06:00
commit e12122a6ed
No known key found for this signature in database
GPG key ID: DE8D5010C0AAA3DC
15 changed files with 927 additions and 0 deletions

37
src/error.rs Normal file
View file

@ -0,0 +1,37 @@
use std::ffi::{c_int, NulError};
use std::str::Utf8Error;
#[derive(Debug, Copy, Clone)]
pub enum WhisperError {
InitError,
SpectrogramNotInitialized,
EncodeNotComplete,
DecodeNotComplete,
InvalidThreadCount,
InvalidUtf8 {
error_len: Option<usize>,
valid_up_to: usize,
},
NullByteInString {
idx: usize,
},
NullPointer,
GenericError(c_int),
}
impl From<Utf8Error> for WhisperError {
fn from(e: Utf8Error) -> Self {
Self::InvalidUtf8 {
error_len: e.error_len(),
valid_up_to: e.valid_up_to(),
}
}
}
impl From<NulError> for WhisperError {
fn from(e: NulError) -> Self {
Self::NullByteInString {
idx: e.nul_position(),
}
}
}