diff --git a/src/audio/capture.rs b/src/audio/capture.rs index ef50856c..008c32d5 100644 --- a/src/audio/capture.rs +++ b/src/audio/capture.rs @@ -117,6 +117,10 @@ unsafe extern "C" fn on_stop_callback(user_data: *mut c_void) impl<'a, R: SoundRecorder> SoundRecorderDriver<'a, R> { /// Creates a new `SoundRecorderDriver` with the specified [`SoundRecorder`]. + /// + /// # Panics + /// + /// Panics if a `SoundRecorderDriver` can't be created for whatever reason pub fn new(sound_recorder: &'a mut R) -> Self { Self { handle: unsafe { @@ -244,6 +248,10 @@ pub struct SoundBufferRecorder { impl SoundBufferRecorder { /// Create a new sound buffer recorder + /// + /// # Panics + /// + /// Panics if a `SoundBufferRecorder` can't be created for whatever reason #[must_use] pub fn new() -> SoundBufferRecorder { let buffer = unsafe { ffi::sfSoundBufferRecorder_new() }; @@ -296,7 +304,7 @@ impl SoundBufferRecorder { #[must_use] pub fn buffer(&self) -> &SoundBuffer { let buff = unsafe { ffi::sfSoundBufferRecorder_getBuffer(self.handle.as_ptr()) }; - assert!(!buff.is_null(), "sfSoundBufferRecorder_getBuffer failed"); + // Safety: getBuffer returns a reference on C++ side, it can never be null or dangling. unsafe { &*(buff) } } /// Get the name of the current audio capture device. diff --git a/src/lib.rs b/src/lib.rs index a7b9c55f..ef8f7d6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,8 @@ clippy::unwrap_used, clippy::unreadable_literal, clippy::ptr_as_ptr, - clippy::cast_lossless + clippy::cast_lossless, + clippy::missing_panics_doc )] extern crate link_cplusplus;