From 0dee7d71dcd6fe48fc32d1157cb51c39995a6c02 Mon Sep 17 00:00:00 2001 From: Ralf Biedert Date: Thu, 4 Apr 2024 12:41:06 +0200 Subject: [PATCH] Add some more #[must_use] --- openh264/src/decoder.rs | 1 + openh264/src/encoder.rs | 1 + openh264/src/formats/mod.rs | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/openh264/src/decoder.rs b/openh264/src/decoder.rs index 1bb6b52..9de1f69 100644 --- a/openh264/src/decoder.rs +++ b/openh264/src/decoder.rs @@ -92,6 +92,7 @@ unsafe impl Sync for DecoderRawAPI {} /// /// Setting missing? Please file a PR! #[derive(Default, Copy, Clone, Debug)] +#[must_use] pub struct DecoderConfig { params: SDecodingParam, num_threads: DECODER_OPTION, diff --git a/openh264/src/encoder.rs b/openh264/src/encoder.rs index f5b5ff7..43eaf68 100644 --- a/openh264/src/encoder.rs +++ b/openh264/src/encoder.rs @@ -166,6 +166,7 @@ impl Default for SpsPpsStrategy { /// /// Setting missing? Please file a PR! #[derive(Default, Copy, Clone, Debug)] +#[must_use] pub struct EncoderConfig { enable_skip_frame: bool, target_bitrate: u32, diff --git a/openh264/src/formats/mod.rs b/openh264/src/formats/mod.rs index 9a9f4b6..3c8e397 100644 --- a/openh264/src/formats/mod.rs +++ b/openh264/src/formats/mod.rs @@ -7,29 +7,36 @@ pub use rgb2yuv::YUVBuffer; /// Allows the [Encoder](crate::encoder::Encoder) to be generic over a YUV source. pub trait YUVSource { /// Size of the image as `(w, h)`. + #[must_use] fn dimension(&self) -> (i32, i32); /// YUV strides as `(y, u, v)`. /// /// For now you should make sure `u == v`. + #[must_use] fn strides(&self) -> (i32, i32, i32); /// Y buffer, should be of size `dimension.1 * strides.0`. + #[must_use] fn y(&self) -> &[u8]; /// U buffer, should be of size `dimension.1 * strides.1`. + #[must_use] fn u(&self) -> &[u8]; /// V buffer, should be of size `dimension.1 * strides.2`. + #[must_use] fn v(&self) -> &[u8]; /// Estimates how many bytes you'll need to store this YUV as RGB. + #[must_use] fn estimate_rgb_size(&self) -> usize { let (w, h) = self.dimension(); w as usize * h as usize * 3 } /// Estimates how many bytes you'll need to store this YUV as RGBA. + #[must_use] fn estimate_rgba_size(&self) -> usize { let (w, h) = self.dimension(); w as usize * h as usize * 4