diff --git a/src/whisper_ctx_wrapper.rs b/src/whisper_ctx_wrapper.rs index 5d2eec8..3635538 100644 --- a/src/whisper_ctx_wrapper.rs +++ b/src/whisper_ctx_wrapper.rs @@ -421,7 +421,7 @@ impl WhisperContext { Err(WhisperError::InitError) } else { // SAFETY: this is known to be a valid pointer to a `whisper_state` struct - Ok(WhisperState::new(self.ctx.clone(), state)) + Ok(unsafe { WhisperState::new(self.ctx.clone(), state) }) } } } diff --git a/src/whisper_state.rs b/src/whisper_state.rs index b5aee36..d6e09ea 100644 --- a/src/whisper_state.rs +++ b/src/whisper_state.rs @@ -29,7 +29,10 @@ impl Drop for WhisperState { } impl WhisperState { - pub(crate) fn new( + /// # Safety + /// * `ptr` must be non-null + /// * `ptr` must be a valid pointer to a `whisper_state`. + pub(crate) unsafe fn new( ctx: Arc, ptr: *mut whisper_rs_sys::whisper_state, ) -> Self {