Skip to content

Commit

Permalink
feat: impl Send/Sync for WebPData (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
amv-dev authored Oct 7, 2023
1 parent c90f50e commit 38a66af
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/webp_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ impl WebPData {
}
}

/// SAFETY: Sending `WebPData` to another thread is safe until there is no way to share internal
/// pointer without borrowing in safe code
unsafe impl Send for WebPData {}

/// SAFETY: Sharing `WebPData` via borrowing is safe until there is no way to share internal
/// pointer without borrowing in safe code
unsafe impl Sync for WebPData {}

impl Drop for WebPData {
fn drop(&mut self) {
unsafe { libwebp_sys::WebPDataClear(self.inner_ref()) }
Expand Down

0 comments on commit 38a66af

Please sign in to comment.