Adjust WhisperState::full() to return () on success

It makes no sense for WhisperState::full() to return an int: the only
possible returned value is 0. Hence, it adds no information whatsoever.
Worse yet, it is confusing everyone using the method. Just return
nothing on success.
This commit is contained in:
Daniel Müller 2025-10-24 08:55:08 -07:00
parent a23990c563
commit c611475bdf
No known key found for this signature in database
GPG key ID: 952DD6F8F34D8B8E

View file

@ -280,7 +280,7 @@ impl WhisperState {
/// See utilities in the root of this crate for functions to convert audio to this format. /// See utilities in the root of this crate for functions to convert audio to this format.
/// ///
/// # Returns /// # Returns
/// Ok(c_int) on success, Err(WhisperError) on failure. /// Ok(()) on success, Err(WhisperError) on failure.
/// ///
/// # C++ equivalent /// # C++ equivalent
/// `int whisper_full_with_state( /// `int whisper_full_with_state(
@ -289,7 +289,7 @@ impl WhisperState {
/// struct whisper_full_params params, /// struct whisper_full_params params,
/// const float * samples, /// const float * samples,
/// int n_samples)` /// int n_samples)`
pub fn full(&mut self, params: FullParams, data: &[f32]) -> Result<c_int, WhisperError> { pub fn full(&mut self, params: FullParams, data: &[f32]) -> Result<(), WhisperError> {
if data.is_empty() { if data.is_empty() {
// can randomly trigger segmentation faults if we don't check this // can randomly trigger segmentation faults if we don't check this
return Err(WhisperError::NoSamples); return Err(WhisperError::NoSamples);
@ -311,7 +311,7 @@ impl WhisperState {
} else if ret == 8 { } else if ret == 8 {
Err(WhisperError::FailedToDecode) Err(WhisperError::FailedToDecode)
} else if ret == 0 { } else if ret == 0 {
Ok(ret) Ok(())
} else { } else {
Err(WhisperError::GenericError(ret)) Err(WhisperError::GenericError(ret))
} }