From ee1a5e8395d0b2d2e07ffd0dd90acd10843c35c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 4 Dec 2021 01:17:29 +0200 Subject: [PATCH] Add #[must_use] attribute to many builders --- gstreamer-app/src/app_sink.rs | 2 ++ gstreamer-app/src/app_src.rs | 2 ++ gstreamer-audio/src/audio_info.rs | 2 ++ gstreamer-audio/src/functions.rs | 4 +-- gstreamer-pbutils/src/encoding_profile.rs | 6 ++++ gstreamer-video/src/functions.rs | 4 +-- gstreamer-video/src/video_event.rs | 4 +++ gstreamer-video/src/video_info.rs | 1 + gstreamer/src/caps.rs | 4 +++ gstreamer/src/event.rs | 32 ++++++++++++++++++ gstreamer/src/message.rs | 40 +++++++++++++++++++++++ gstreamer/src/pad.rs | 2 ++ gstreamer/src/sample.rs | 2 ++ gstreamer/src/stream_collection.rs | 2 ++ gstreamer/src/structure.rs | 2 ++ 15 files changed, 105 insertions(+), 4 deletions(-) diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index 9d2775321..cd68bcaec 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -54,6 +54,7 @@ impl AppSinkCallbacks { } #[allow(clippy::type_complexity)] +#[must_use = "The builder must be built to be used"] pub struct AppSinkCallbacksBuilder { eos: Option>>, new_preroll: Option< @@ -110,6 +111,7 @@ impl AppSinkCallbacksBuilder { } } + #[must_use = "Building the callbacks without using them has no effect"] pub fn build(self) -> AppSinkCallbacks { let have_eos = self.eos.is_some(); let have_new_preroll = self.new_preroll.is_some(); diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index 91c88f691..f002fc8a2 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -40,6 +40,7 @@ impl AppSrcCallbacks { } #[allow(clippy::type_complexity)] +#[must_use = "The builder must be built to be used"] pub struct AppSrcCallbacksBuilder { need_data: Option>>, enough_data: Option>, @@ -71,6 +72,7 @@ impl AppSrcCallbacksBuilder { } } + #[must_use = "Building the callbacks without using them has no effect"] pub fn build(self) -> AppSrcCallbacks { let have_need_data = self.need_data.is_some(); let have_enough_data = self.enough_data.is_some(); diff --git a/gstreamer-audio/src/audio_info.rs b/gstreamer-audio/src/audio_info.rs index f480096ea..4eaabbea9 100644 --- a/gstreamer-audio/src/audio_info.rs +++ b/gstreamer-audio/src/audio_info.rs @@ -26,6 +26,7 @@ impl fmt::Debug for AudioInfo { } #[derive(Debug)] +#[must_use = "The builder must be built to be used"] pub struct AudioInfoBuilder<'a> { format: crate::AudioFormat, rate: u32, @@ -36,6 +37,7 @@ pub struct AudioInfoBuilder<'a> { } impl<'a> AudioInfoBuilder<'a> { + #[must_use = "The built AudioInfo must be used"] pub fn build(self) -> Result { unsafe { let mut info = mem::MaybeUninit::uninit(); diff --git a/gstreamer-audio/src/functions.rs b/gstreamer-audio/src/functions.rs index eafb8cb99..4912f6599 100644 --- a/gstreamer-audio/src/functions.rs +++ b/gstreamer-audio/src/functions.rs @@ -122,7 +122,7 @@ mod tests { #[should_panic(expected = "Invalid encoded format")] fn audio_caps_encoded() { gst::init().unwrap(); - audio_make_raw_caps( + let _caps = audio_make_raw_caps( &[crate::AudioFormat::Encoded], crate::AudioLayout::Interleaved, ); @@ -132,7 +132,7 @@ mod tests { #[should_panic(expected = "Invalid unknown format")] fn audio_caps_unknown() { gst::init().unwrap(); - audio_make_raw_caps( + let _caps = audio_make_raw_caps( &[crate::AudioFormat::Unknown], crate::AudioLayout::Interleaved, ); diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index 39b075a7c..98b825c3e 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -400,6 +400,7 @@ fn set_common_fields( } #[derive(Debug)] +#[must_use = "The builder must be built to be used"] pub struct EncodingAudioProfileBuilder<'a> { base: EncodingProfileBuilderCommonData<'a>, restriction: Option<&'a gst::Caps>, @@ -422,6 +423,7 @@ impl<'a> EncodingAudioProfileBuilder<'a> { self } + #[must_use = "Building the profile without using it has no effect"] pub fn build(self) -> EncodingAudioProfile { let profile = EncodingAudioProfile::new( self.base.format, @@ -437,6 +439,7 @@ impl<'a> EncodingAudioProfileBuilder<'a> { } #[derive(Debug)] +#[must_use = "The builder must be built to be used"] pub struct EncodingVideoProfileBuilder<'a> { base: EncodingProfileBuilderCommonData<'a>, restriction: Option<&'a gst::Caps>, @@ -475,6 +478,7 @@ impl<'a> EncodingVideoProfileBuilder<'a> { self } + #[must_use = "Building the profile without using it has no effect"] pub fn build(self) -> EncodingVideoProfile { let video_profile = EncodingVideoProfile::new( self.base.format, @@ -493,6 +497,7 @@ impl<'a> EncodingVideoProfileBuilder<'a> { } #[derive(Debug)] +#[must_use = "The builder must be built to be used"] pub struct EncodingContainerProfileBuilder<'a> { base: EncodingProfileBuilderCommonData<'a>, profiles: Vec, @@ -509,6 +514,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> { } } + #[must_use = "Building the profile without using it has no effect"] pub fn build(self) -> EncodingContainerProfile { let container_profile = EncodingContainerProfile::new( self.base.name, diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index 5783597b4..a9293f0a3 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -316,13 +316,13 @@ mod tests { #[should_panic(expected = "Invalid encoded format")] fn video_caps_encoded() { gst::init().unwrap(); - video_make_raw_caps(&[crate::VideoFormat::Encoded]); + let _caps = video_make_raw_caps(&[crate::VideoFormat::Encoded]); } #[test] #[should_panic(expected = "Invalid unknown format")] fn video_caps_unknown() { gst::init().unwrap(); - video_make_raw_caps(&[crate::VideoFormat::Unknown]); + let _caps = video_make_raw_caps(&[crate::VideoFormat::Unknown]); } } diff --git a/gstreamer-video/src/video_event.rs b/gstreamer-video/src/video_event.rs index 30c95acf6..958db43ae 100644 --- a/gstreamer-video/src/video_event.rs +++ b/gstreamer-video/src/video_event.rs @@ -36,6 +36,7 @@ macro_rules! event_builder_generic_impl { } } + #[must_use = "Building the event without using it has no effect"] pub fn build(mut self) -> gst::Event { assert_initialized_main_thread!(); unsafe { @@ -64,6 +65,7 @@ macro_rules! event_builder_generic_impl { }; } +#[must_use = "The builder must be built to be used"] pub struct DownstreamForceKeyUnitEventBuilder<'a> { seqnum: Option, running_time_offset: Option, @@ -180,6 +182,7 @@ impl DownstreamForceKeyUnitEvent { } } +#[must_use = "The builder must be built to be used"] pub struct UpstreamForceKeyUnitEventBuilder<'a> { seqnum: Option, running_time_offset: Option, @@ -291,6 +294,7 @@ impl ForceKeyUnitEvent { } } +#[must_use = "The builder must be built to be used"] pub struct StillFrameEventBuilder<'a> { seqnum: Option, running_time_offset: Option, diff --git a/gstreamer-video/src/video_info.rs b/gstreamer-video/src/video_info.rs index d0569f1fc..ba16adab2 100644 --- a/gstreamer-video/src/video_info.rs +++ b/gstreamer-video/src/video_info.rs @@ -272,6 +272,7 @@ impl fmt::Debug for VideoInfo { } #[derive(Debug)] +#[must_use = "The builder must be built to be used"] pub struct VideoInfoBuilder<'a> { format: crate::VideoFormat, width: u32, diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 78bcf14f6..89880491c 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -662,6 +662,7 @@ impl Eq for CapsRef {} pub enum NoFeature {} pub enum HasFeatures {} +#[must_use = "The builder must be built to be used"] pub struct Builder { s: crate::Structure, features: Option, @@ -711,6 +712,7 @@ impl Builder { self } + #[must_use = "Building the caps without using them has no effect"] pub fn build(self) -> Caps { let mut caps = Caps::new_empty(); @@ -724,6 +726,7 @@ impl Builder { pub enum AnyFeatures {} pub enum SomeFeatures {} +#[must_use = "The builder must be built to be used"] pub struct BuilderFull { caps: crate::Caps, features: Option, @@ -806,6 +809,7 @@ impl BuilderFull { self.append_structure(structure, None) } + #[must_use = "Building the caps without using them has no effect"] pub fn build(self) -> Caps { self.caps } diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index e4e30d290..3d47e67cd 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -1563,6 +1563,7 @@ macro_rules! event_builder_generic_impl { } } + #[must_use = "Building the event without using it has no effect"] pub fn build(mut self) -> Event { assert_initialized_main_thread!(); unsafe { @@ -1591,6 +1592,7 @@ macro_rules! event_builder_generic_impl { }; } +#[must_use = "The builder must be built to be used"] pub struct FlushStartBuilder<'a> { builder: EventBuilder<'a>, } @@ -1606,6 +1608,7 @@ impl<'a> FlushStartBuilder<'a> { event_builder_generic_impl!(|_| { ffi::gst_event_new_flush_start() }); } +#[must_use = "The builder must be built to be used"] pub struct FlushStopBuilder<'a> { builder: EventBuilder<'a>, reset_time: bool, @@ -1624,6 +1627,7 @@ impl<'a> FlushStopBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct StreamStartBuilder<'a> { builder: EventBuilder<'a>, stream_id: &'a str, @@ -1689,6 +1693,7 @@ impl<'a> StreamStartBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct CapsBuilder<'a> { builder: EventBuilder<'a>, caps: &'a crate::Caps, @@ -1706,6 +1711,7 @@ impl<'a> CapsBuilder<'a> { event_builder_generic_impl!(|s: &Self| { ffi::gst_event_new_caps(s.caps.as_mut_ptr()) }); } +#[must_use = "The builder must be built to be used"] pub struct SegmentBuilder<'a> { builder: EventBuilder<'a>, segment: &'a crate::Segment, @@ -1727,6 +1733,7 @@ impl<'a> SegmentBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[must_use = "The builder must be built to be used"] pub struct StreamCollectionBuilder<'a> { builder: EventBuilder<'a>, stream_collection: &'a crate::StreamCollection, @@ -1750,6 +1757,7 @@ impl<'a> StreamCollectionBuilder<'a> { #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] +#[must_use = "The builder must be built to be used"] pub struct InstantRateSyncTimeBuilder<'a> { builder: EventBuilder<'a>, rate_multiplier: f64, @@ -1783,6 +1791,7 @@ impl<'a> InstantRateSyncTimeBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct TagBuilder<'a> { builder: EventBuilder<'a>, tags: Option, @@ -1803,6 +1812,7 @@ impl<'a> TagBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct BuffersizeBuilder<'a> { builder: EventBuilder<'a>, minsize: GenericFormattedValue, @@ -1831,6 +1841,7 @@ impl<'a> BuffersizeBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct SinkMessageBuilder<'a> { builder: EventBuilder<'a>, name: &'a str, @@ -1854,6 +1865,7 @@ impl<'a> SinkMessageBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[must_use = "The builder must be built to be used"] pub struct StreamGroupDoneBuilder<'a> { builder: EventBuilder<'a>, group_id: GroupId, @@ -1875,6 +1887,7 @@ impl<'a> StreamGroupDoneBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct EosBuilder<'a> { builder: EventBuilder<'a>, } @@ -1890,6 +1903,7 @@ impl<'a> EosBuilder<'a> { event_builder_generic_impl!(|_| ffi::gst_event_new_eos()); } +#[must_use = "The builder must be built to be used"] pub struct TocBuilder<'a> { builder: EventBuilder<'a>, toc: &'a crate::Toc, @@ -1912,6 +1926,7 @@ impl<'a> TocBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct ProtectionBuilder<'a> { builder: EventBuilder<'a>, system_id: &'a str, @@ -1946,6 +1961,7 @@ impl<'a> ProtectionBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct SegmentDoneBuilder<'a> { builder: EventBuilder<'a>, position: GenericFormattedValue, @@ -1965,6 +1981,7 @@ impl<'a> SegmentDoneBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct GapBuilder<'a> { builder: EventBuilder<'a>, timestamp: ClockTime, @@ -2012,6 +2029,7 @@ impl<'a> GapBuilder<'a> { #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] +#[must_use = "The builder must be built to be used"] pub struct InstantRateChangeBuilder<'a> { builder: EventBuilder<'a>, multiplier: f64, @@ -2036,6 +2054,7 @@ impl<'a> InstantRateChangeBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct QosBuilder<'a> { builder: EventBuilder<'a>, type_: crate::QOSType, @@ -2069,6 +2088,7 @@ impl<'a> QosBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct SeekBuilder<'a> { builder: EventBuilder<'a>, rate: f64, @@ -2131,6 +2151,7 @@ impl<'a> SeekBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct NavigationBuilder<'a> { builder: EventBuilder<'a>, structure: Option, @@ -2151,6 +2172,7 @@ impl<'a> NavigationBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct LatencyBuilder<'a> { builder: EventBuilder<'a>, latency: ClockTime, @@ -2168,6 +2190,7 @@ impl<'a> LatencyBuilder<'a> { event_builder_generic_impl!(|s: &Self| { ffi::gst_event_new_latency(s.latency.into_glib()) }); } +#[must_use = "The builder must be built to be used"] pub struct StepBuilder<'a> { builder: EventBuilder<'a>, amount: GenericFormattedValue, @@ -2199,6 +2222,7 @@ impl<'a> StepBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct ReconfigureBuilder<'a> { builder: EventBuilder<'a>, } @@ -2214,6 +2238,7 @@ impl<'a> ReconfigureBuilder<'a> { event_builder_generic_impl!(|_| { ffi::gst_event_new_reconfigure() }); } +#[must_use = "The builder must be built to be used"] pub struct TocSelectBuilder<'a> { builder: EventBuilder<'a>, uid: &'a str, @@ -2235,6 +2260,7 @@ impl<'a> TocSelectBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[must_use = "The builder must be built to be used"] pub struct SelectStreamsBuilder<'a> { builder: EventBuilder<'a>, streams: &'a [&'a str], @@ -2256,6 +2282,7 @@ impl<'a> SelectStreamsBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct CustomUpstreamBuilder<'a> { builder: EventBuilder<'a>, structure: Option, @@ -2276,6 +2303,7 @@ impl<'a> CustomUpstreamBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct CustomDownstreamBuilder<'a> { builder: EventBuilder<'a>, structure: Option, @@ -2296,6 +2324,7 @@ impl<'a> CustomDownstreamBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct CustomDownstreamOobBuilder<'a> { builder: EventBuilder<'a>, structure: Option, @@ -2316,6 +2345,7 @@ impl<'a> CustomDownstreamOobBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct CustomDownstreamStickyBuilder<'a> { builder: EventBuilder<'a>, structure: Option, @@ -2339,6 +2369,7 @@ impl<'a> CustomDownstreamStickyBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct CustomBothBuilder<'a> { builder: EventBuilder<'a>, structure: Option, @@ -2359,6 +2390,7 @@ impl<'a> CustomBothBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct CustomBothOobBuilder<'a> { builder: EventBuilder<'a>, structure: Option, diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 843782bce..a29ce98bb 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -1796,6 +1796,7 @@ macro_rules! message_builder_generic_impl { } } + #[must_use = "Building the message without using it has no effect"] pub fn build(mut self) -> Message { assert_initialized_main_thread!(); unsafe { @@ -1824,6 +1825,7 @@ macro_rules! message_builder_generic_impl { }; } +#[must_use = "The builder must be built to be used"] pub struct EosBuilder<'a> { builder: MessageBuilder<'a>, } @@ -1846,6 +1848,7 @@ impl MessageErrorDomain for crate::ResourceError {} impl MessageErrorDomain for crate::StreamError {} impl MessageErrorDomain for crate::LibraryError {} +#[must_use = "The builder must be built to be used"] pub struct ErrorBuilder<'a, T> { builder: MessageBuilder<'a>, error: T, @@ -1912,6 +1915,7 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> { }); } +#[must_use = "The builder must be built to be used"] pub struct WarningBuilder<'a, T> { builder: MessageBuilder<'a>, error: T, @@ -1978,6 +1982,7 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> { }); } +#[must_use = "The builder must be built to be used"] pub struct InfoBuilder<'a, T> { builder: MessageBuilder<'a>, error: T, @@ -2044,6 +2049,7 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> { }); } +#[must_use = "The builder must be built to be used"] pub struct TagBuilder<'a> { builder: MessageBuilder<'a>, tags: &'a TagList, @@ -2064,6 +2070,7 @@ impl<'a> TagBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct BufferingBuilder<'a> { builder: MessageBuilder<'a>, percent: i32, @@ -2111,6 +2118,7 @@ impl<'a> BufferingBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct StateChangedBuilder<'a> { builder: MessageBuilder<'a>, old: crate::State, @@ -2137,6 +2145,7 @@ impl<'a> StateChangedBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct StateDirtyBuilder<'a> { builder: MessageBuilder<'a>, } @@ -2152,6 +2161,7 @@ impl<'a> StateDirtyBuilder<'a> { message_builder_generic_impl!(|_, src| ffi::gst_message_new_state_dirty(src)); } +#[must_use = "The builder must be built to be used"] pub struct StepDoneBuilder<'a> { builder: MessageBuilder<'a>, amount: GenericFormattedValue, @@ -2196,6 +2206,7 @@ impl<'a> StepDoneBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct ClockProvideBuilder<'a> { builder: MessageBuilder<'a>, clock: &'a crate::Clock, @@ -2219,6 +2230,7 @@ impl<'a> ClockProvideBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct ClockLostBuilder<'a> { builder: MessageBuilder<'a>, clock: &'a crate::Clock, @@ -2239,6 +2251,7 @@ impl<'a> ClockLostBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct NewClockBuilder<'a> { builder: MessageBuilder<'a>, clock: &'a crate::Clock, @@ -2259,6 +2272,7 @@ impl<'a> NewClockBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct StructureChangeBuilder<'a> { builder: MessageBuilder<'a>, type_: crate::StructureChangeType, @@ -2285,6 +2299,7 @@ impl<'a> StructureChangeBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct StreamStatusBuilder<'a> { builder: MessageBuilder<'a>, type_: crate::StreamStatusType, @@ -2323,6 +2338,7 @@ impl<'a> StreamStatusBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct ApplicationBuilder<'a> { builder: MessageBuilder<'a>, structure: Option, @@ -2343,6 +2359,7 @@ impl<'a> ApplicationBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct ElementBuilder<'a> { builder: MessageBuilder<'a>, structure: Option, @@ -2363,6 +2380,7 @@ impl<'a> ElementBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct SegmentStartBuilder<'a> { builder: MessageBuilder<'a>, position: GenericFormattedValue, @@ -2384,6 +2402,7 @@ impl<'a> SegmentStartBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct SegmentDoneBuilder<'a> { builder: MessageBuilder<'a>, position: GenericFormattedValue, @@ -2405,6 +2424,7 @@ impl<'a> SegmentDoneBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct DurationChangedBuilder<'a> { builder: MessageBuilder<'a>, } @@ -2420,6 +2440,7 @@ impl<'a> DurationChangedBuilder<'a> { message_builder_generic_impl!(|_, src| ffi::gst_message_new_duration_changed(src)); } +#[must_use = "The builder must be built to be used"] pub struct LatencyBuilder<'a> { builder: MessageBuilder<'a>, } @@ -2435,6 +2456,7 @@ impl<'a> LatencyBuilder<'a> { message_builder_generic_impl!(|_, src| ffi::gst_message_new_latency(src)); } +#[must_use = "The builder must be built to be used"] pub struct AsyncStartBuilder<'a> { builder: MessageBuilder<'a>, } @@ -2450,6 +2472,7 @@ impl<'a> AsyncStartBuilder<'a> { message_builder_generic_impl!(|_, src| ffi::gst_message_new_async_start(src)); } +#[must_use = "The builder must be built to be used"] pub struct AsyncDoneBuilder<'a> { builder: MessageBuilder<'a>, running_time: Option, @@ -2475,6 +2498,7 @@ impl<'a> AsyncDoneBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct RequestStateBuilder<'a> { builder: MessageBuilder<'a>, state: crate::State, @@ -2495,6 +2519,7 @@ impl<'a> RequestStateBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct StepStartBuilder<'a> { builder: MessageBuilder<'a>, active: bool, @@ -2534,6 +2559,7 @@ impl<'a> StepStartBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct QosBuilder<'a> { builder: MessageBuilder<'a>, live: bool, @@ -2621,6 +2647,7 @@ impl<'a> QosBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct ProgressBuilder<'a> { builder: MessageBuilder<'a>, type_: crate::ProgressType, @@ -2647,6 +2674,7 @@ impl<'a> ProgressBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct TocBuilder<'a> { builder: MessageBuilder<'a>, toc: &'a crate::Toc, @@ -2670,6 +2698,7 @@ impl<'a> TocBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct ResetTimeBuilder<'a> { builder: MessageBuilder<'a>, running_time: crate::ClockTime, @@ -2690,6 +2719,7 @@ impl<'a> ResetTimeBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct StreamStartBuilder<'a> { builder: MessageBuilder<'a>, group_id: Option, @@ -2720,6 +2750,7 @@ impl<'a> StreamStartBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct NeedContextBuilder<'a> { builder: MessageBuilder<'a>, context_type: &'a str, @@ -2740,6 +2771,7 @@ impl<'a> NeedContextBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct HaveContextBuilder<'a> { builder: MessageBuilder<'a>, context: Option, @@ -2760,6 +2792,7 @@ impl<'a> HaveContextBuilder<'a> { }); } +#[must_use = "The builder must be built to be used"] pub struct DeviceAddedBuilder<'a> { builder: MessageBuilder<'a>, device: &'a crate::Device, @@ -2780,6 +2813,7 @@ impl<'a> DeviceAddedBuilder<'a> { )); } +#[must_use = "The builder must be built to be used"] pub struct DeviceRemovedBuilder<'a> { builder: MessageBuilder<'a>, device: &'a crate::Device, @@ -2802,6 +2836,7 @@ impl<'a> DeviceRemovedBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[must_use = "The builder must be built to be used"] pub struct PropertyNotifyBuilder<'a> { builder: MessageBuilder<'a>, property_name: &'a str, @@ -2843,6 +2878,7 @@ impl<'a> PropertyNotifyBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[must_use = "The builder must be built to be used"] pub struct StreamCollectionBuilder<'a> { builder: MessageBuilder<'a>, collection: &'a crate::StreamCollection, @@ -2866,6 +2902,7 @@ impl<'a> StreamCollectionBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[must_use = "The builder must be built to be used"] pub struct StreamsSelectedBuilder<'a> { builder: MessageBuilder<'a>, #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -2908,6 +2945,7 @@ impl<'a> StreamsSelectedBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[must_use = "The builder must be built to be used"] pub struct RedirectBuilder<'a> { builder: MessageBuilder<'a>, location: &'a str, @@ -2992,6 +3030,7 @@ impl<'a> RedirectBuilder<'a> { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] +#[must_use = "The builder must be built to be used"] pub struct DeviceChangedBuilder<'a> { builder: MessageBuilder<'a>, device: &'a crate::Device, @@ -3019,6 +3058,7 @@ impl<'a> DeviceChangedBuilder<'a> { #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] +#[must_use = "The builder must be built to be used"] pub struct InstantRateRequestBuilder<'a> { builder: MessageBuilder<'a>, rate_multiplier: f64, diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index efe331f3e..5aecc2152 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -1618,6 +1618,7 @@ impl Pad { } } +#[must_use = "The builder must be built to be used"] pub struct PadBuilder(pub(crate) T); impl + IsA + glib::object::IsClass> PadBuilder { @@ -1847,6 +1848,7 @@ impl + IsA + glib::object::IsClass> PadBuilder { self } + #[must_use = "Building the pad without using it has no effect"] pub fn build(self) -> T { self.0 } diff --git a/gstreamer/src/sample.rs b/gstreamer/src/sample.rs index 0e408021e..3a74fe3e7 100644 --- a/gstreamer/src/sample.rs +++ b/gstreamer/src/sample.rs @@ -22,6 +22,7 @@ mini_object_wrapper!(Sample, SampleRef, ffi::GstSample, || { }); #[derive(Debug, Clone)] +#[must_use = "The builder must be built to be used"] pub struct SampleBuilder<'a> { buffer: Option<&'a Buffer>, buffer_list: Option<&'a BufferList>, @@ -68,6 +69,7 @@ impl<'a> SampleBuilder<'a> { } } + #[must_use = "Building the sample without using it has no effect"] pub fn build(self) -> Sample { assert_initialized_main_thread!(); diff --git a/gstreamer/src/stream_collection.rs b/gstreamer/src/stream_collection.rs index c62535390..55ec0bbc7 100644 --- a/gstreamer/src/stream_collection.rs +++ b/gstreamer/src/stream_collection.rs @@ -67,6 +67,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> { impl<'a> ExactSizeIterator for Iter<'a> {} #[derive(Debug, Clone)] +#[must_use = "The builder must be built to be used"] pub struct StreamCollectionBuilder(StreamCollection); impl StreamCollectionBuilder { @@ -92,6 +93,7 @@ impl StreamCollectionBuilder { self } + #[must_use = "Building the stream collection without using it has no effect"] pub fn build(self) -> StreamCollection { self.0 } diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 75eb3dded..894210c1f 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -864,6 +864,7 @@ impl std::iter::Extend<(glib::Quark, SendValue)> for StructureRef { } #[derive(Debug)] +#[must_use = "The builder must be built to be used"] pub struct Builder { s: Structure, } @@ -881,6 +882,7 @@ impl Builder { self } + #[must_use = "Building the structure without using it has no effect"] pub fn build(self) -> Structure { self.s }