Add #[must_use] attribute to many builders

This commit is contained in:
Sebastian Dröge 2021-12-04 01:17:29 +02:00
parent 8f3ed6d289
commit ee1a5e8395
15 changed files with 105 additions and 4 deletions

View file

@ -54,6 +54,7 @@ impl AppSinkCallbacks {
} }
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
#[must_use = "The builder must be built to be used"]
pub struct AppSinkCallbacksBuilder { pub struct AppSinkCallbacksBuilder {
eos: Option<RefCell<Box<dyn FnMut(&AppSink) + Send + 'static>>>, eos: Option<RefCell<Box<dyn FnMut(&AppSink) + Send + 'static>>>,
new_preroll: 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 { pub fn build(self) -> AppSinkCallbacks {
let have_eos = self.eos.is_some(); let have_eos = self.eos.is_some();
let have_new_preroll = self.new_preroll.is_some(); let have_new_preroll = self.new_preroll.is_some();

View file

@ -40,6 +40,7 @@ impl AppSrcCallbacks {
} }
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
#[must_use = "The builder must be built to be used"]
pub struct AppSrcCallbacksBuilder { pub struct AppSrcCallbacksBuilder {
need_data: Option<RefCell<Box<dyn FnMut(&AppSrc, u32) + Send + 'static>>>, need_data: Option<RefCell<Box<dyn FnMut(&AppSrc, u32) + Send + 'static>>>,
enough_data: Option<Box<dyn Fn(&AppSrc) + Send + Sync + 'static>>, enough_data: Option<Box<dyn Fn(&AppSrc) + Send + Sync + 'static>>,
@ -71,6 +72,7 @@ impl AppSrcCallbacksBuilder {
} }
} }
#[must_use = "Building the callbacks without using them has no effect"]
pub fn build(self) -> AppSrcCallbacks { pub fn build(self) -> AppSrcCallbacks {
let have_need_data = self.need_data.is_some(); let have_need_data = self.need_data.is_some();
let have_enough_data = self.enough_data.is_some(); let have_enough_data = self.enough_data.is_some();

View file

@ -26,6 +26,7 @@ impl fmt::Debug for AudioInfo {
} }
#[derive(Debug)] #[derive(Debug)]
#[must_use = "The builder must be built to be used"]
pub struct AudioInfoBuilder<'a> { pub struct AudioInfoBuilder<'a> {
format: crate::AudioFormat, format: crate::AudioFormat,
rate: u32, rate: u32,
@ -36,6 +37,7 @@ pub struct AudioInfoBuilder<'a> {
} }
impl<'a> AudioInfoBuilder<'a> { impl<'a> AudioInfoBuilder<'a> {
#[must_use = "The built AudioInfo must be used"]
pub fn build(self) -> Result<AudioInfo, glib::error::BoolError> { pub fn build(self) -> Result<AudioInfo, glib::error::BoolError> {
unsafe { unsafe {
let mut info = mem::MaybeUninit::uninit(); let mut info = mem::MaybeUninit::uninit();

View file

@ -122,7 +122,7 @@ mod tests {
#[should_panic(expected = "Invalid encoded format")] #[should_panic(expected = "Invalid encoded format")]
fn audio_caps_encoded() { fn audio_caps_encoded() {
gst::init().unwrap(); gst::init().unwrap();
audio_make_raw_caps( let _caps = audio_make_raw_caps(
&[crate::AudioFormat::Encoded], &[crate::AudioFormat::Encoded],
crate::AudioLayout::Interleaved, crate::AudioLayout::Interleaved,
); );
@ -132,7 +132,7 @@ mod tests {
#[should_panic(expected = "Invalid unknown format")] #[should_panic(expected = "Invalid unknown format")]
fn audio_caps_unknown() { fn audio_caps_unknown() {
gst::init().unwrap(); gst::init().unwrap();
audio_make_raw_caps( let _caps = audio_make_raw_caps(
&[crate::AudioFormat::Unknown], &[crate::AudioFormat::Unknown],
crate::AudioLayout::Interleaved, crate::AudioLayout::Interleaved,
); );

View file

@ -400,6 +400,7 @@ fn set_common_fields<T: EncodingProfileBuilderCommon>(
} }
#[derive(Debug)] #[derive(Debug)]
#[must_use = "The builder must be built to be used"]
pub struct EncodingAudioProfileBuilder<'a> { pub struct EncodingAudioProfileBuilder<'a> {
base: EncodingProfileBuilderCommonData<'a>, base: EncodingProfileBuilderCommonData<'a>,
restriction: Option<&'a gst::Caps>, restriction: Option<&'a gst::Caps>,
@ -422,6 +423,7 @@ impl<'a> EncodingAudioProfileBuilder<'a> {
self self
} }
#[must_use = "Building the profile without using it has no effect"]
pub fn build(self) -> EncodingAudioProfile { pub fn build(self) -> EncodingAudioProfile {
let profile = EncodingAudioProfile::new( let profile = EncodingAudioProfile::new(
self.base.format, self.base.format,
@ -437,6 +439,7 @@ impl<'a> EncodingAudioProfileBuilder<'a> {
} }
#[derive(Debug)] #[derive(Debug)]
#[must_use = "The builder must be built to be used"]
pub struct EncodingVideoProfileBuilder<'a> { pub struct EncodingVideoProfileBuilder<'a> {
base: EncodingProfileBuilderCommonData<'a>, base: EncodingProfileBuilderCommonData<'a>,
restriction: Option<&'a gst::Caps>, restriction: Option<&'a gst::Caps>,
@ -475,6 +478,7 @@ impl<'a> EncodingVideoProfileBuilder<'a> {
self self
} }
#[must_use = "Building the profile without using it has no effect"]
pub fn build(self) -> EncodingVideoProfile { pub fn build(self) -> EncodingVideoProfile {
let video_profile = EncodingVideoProfile::new( let video_profile = EncodingVideoProfile::new(
self.base.format, self.base.format,
@ -493,6 +497,7 @@ impl<'a> EncodingVideoProfileBuilder<'a> {
} }
#[derive(Debug)] #[derive(Debug)]
#[must_use = "The builder must be built to be used"]
pub struct EncodingContainerProfileBuilder<'a> { pub struct EncodingContainerProfileBuilder<'a> {
base: EncodingProfileBuilderCommonData<'a>, base: EncodingProfileBuilderCommonData<'a>,
profiles: Vec<EncodingProfile>, profiles: Vec<EncodingProfile>,
@ -509,6 +514,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> {
} }
} }
#[must_use = "Building the profile without using it has no effect"]
pub fn build(self) -> EncodingContainerProfile { pub fn build(self) -> EncodingContainerProfile {
let container_profile = EncodingContainerProfile::new( let container_profile = EncodingContainerProfile::new(
self.base.name, self.base.name,

View file

@ -316,13 +316,13 @@ mod tests {
#[should_panic(expected = "Invalid encoded format")] #[should_panic(expected = "Invalid encoded format")]
fn video_caps_encoded() { fn video_caps_encoded() {
gst::init().unwrap(); gst::init().unwrap();
video_make_raw_caps(&[crate::VideoFormat::Encoded]); let _caps = video_make_raw_caps(&[crate::VideoFormat::Encoded]);
} }
#[test] #[test]
#[should_panic(expected = "Invalid unknown format")] #[should_panic(expected = "Invalid unknown format")]
fn video_caps_unknown() { fn video_caps_unknown() {
gst::init().unwrap(); gst::init().unwrap();
video_make_raw_caps(&[crate::VideoFormat::Unknown]); let _caps = video_make_raw_caps(&[crate::VideoFormat::Unknown]);
} }
} }

View file

@ -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 { pub fn build(mut self) -> gst::Event {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { 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> { pub struct DownstreamForceKeyUnitEventBuilder<'a> {
seqnum: Option<gst::Seqnum>, seqnum: Option<gst::Seqnum>,
running_time_offset: Option<i64>, running_time_offset: Option<i64>,
@ -180,6 +182,7 @@ impl DownstreamForceKeyUnitEvent {
} }
} }
#[must_use = "The builder must be built to be used"]
pub struct UpstreamForceKeyUnitEventBuilder<'a> { pub struct UpstreamForceKeyUnitEventBuilder<'a> {
seqnum: Option<gst::Seqnum>, seqnum: Option<gst::Seqnum>,
running_time_offset: Option<i64>, running_time_offset: Option<i64>,
@ -291,6 +294,7 @@ impl ForceKeyUnitEvent {
} }
} }
#[must_use = "The builder must be built to be used"]
pub struct StillFrameEventBuilder<'a> { pub struct StillFrameEventBuilder<'a> {
seqnum: Option<gst::Seqnum>, seqnum: Option<gst::Seqnum>,
running_time_offset: Option<i64>, running_time_offset: Option<i64>,

View file

@ -272,6 +272,7 @@ impl fmt::Debug for VideoInfo {
} }
#[derive(Debug)] #[derive(Debug)]
#[must_use = "The builder must be built to be used"]
pub struct VideoInfoBuilder<'a> { pub struct VideoInfoBuilder<'a> {
format: crate::VideoFormat, format: crate::VideoFormat,
width: u32, width: u32,

View file

@ -662,6 +662,7 @@ impl Eq for CapsRef {}
pub enum NoFeature {} pub enum NoFeature {}
pub enum HasFeatures {} pub enum HasFeatures {}
#[must_use = "The builder must be built to be used"]
pub struct Builder<T> { pub struct Builder<T> {
s: crate::Structure, s: crate::Structure,
features: Option<CapsFeatures>, features: Option<CapsFeatures>,
@ -711,6 +712,7 @@ impl<T> Builder<T> {
self self
} }
#[must_use = "Building the caps without using them has no effect"]
pub fn build(self) -> Caps { pub fn build(self) -> Caps {
let mut caps = Caps::new_empty(); let mut caps = Caps::new_empty();
@ -724,6 +726,7 @@ impl<T> Builder<T> {
pub enum AnyFeatures {} pub enum AnyFeatures {}
pub enum SomeFeatures {} pub enum SomeFeatures {}
#[must_use = "The builder must be built to be used"]
pub struct BuilderFull<T> { pub struct BuilderFull<T> {
caps: crate::Caps, caps: crate::Caps,
features: Option<CapsFeatures>, features: Option<CapsFeatures>,
@ -806,6 +809,7 @@ impl<T> BuilderFull<T> {
self.append_structure(structure, None) self.append_structure(structure, None)
} }
#[must_use = "Building the caps without using them has no effect"]
pub fn build(self) -> Caps { pub fn build(self) -> Caps {
self.caps self.caps
} }

View file

@ -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 { pub fn build(mut self) -> Event {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { 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> { pub struct FlushStartBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
} }
@ -1606,6 +1608,7 @@ impl<'a> FlushStartBuilder<'a> {
event_builder_generic_impl!(|_| { ffi::gst_event_new_flush_start() }); event_builder_generic_impl!(|_| { ffi::gst_event_new_flush_start() });
} }
#[must_use = "The builder must be built to be used"]
pub struct FlushStopBuilder<'a> { pub struct FlushStopBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
reset_time: bool, 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> { pub struct StreamStartBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
stream_id: &'a str, 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> { pub struct CapsBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
caps: &'a crate::Caps, 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()) }); 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> { pub struct SegmentBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
segment: &'a crate::Segment, segment: &'a crate::Segment,
@ -1727,6 +1733,7 @@ impl<'a> SegmentBuilder<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[must_use = "The builder must be built to be used"]
pub struct StreamCollectionBuilder<'a> { pub struct StreamCollectionBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
stream_collection: &'a crate::StreamCollection, stream_collection: &'a crate::StreamCollection,
@ -1750,6 +1757,7 @@ impl<'a> StreamCollectionBuilder<'a> {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[must_use = "The builder must be built to be used"]
pub struct InstantRateSyncTimeBuilder<'a> { pub struct InstantRateSyncTimeBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
rate_multiplier: f64, 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> { pub struct TagBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
tags: Option<crate::TagList>, tags: Option<crate::TagList>,
@ -1803,6 +1812,7 @@ impl<'a> TagBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct BuffersizeBuilder<'a> { pub struct BuffersizeBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
minsize: GenericFormattedValue, minsize: GenericFormattedValue,
@ -1831,6 +1841,7 @@ impl<'a> BuffersizeBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct SinkMessageBuilder<'a> { pub struct SinkMessageBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
name: &'a str, name: &'a str,
@ -1854,6 +1865,7 @@ impl<'a> SinkMessageBuilder<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[must_use = "The builder must be built to be used"]
pub struct StreamGroupDoneBuilder<'a> { pub struct StreamGroupDoneBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
group_id: GroupId, 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> { pub struct EosBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
} }
@ -1890,6 +1903,7 @@ impl<'a> EosBuilder<'a> {
event_builder_generic_impl!(|_| ffi::gst_event_new_eos()); event_builder_generic_impl!(|_| ffi::gst_event_new_eos());
} }
#[must_use = "The builder must be built to be used"]
pub struct TocBuilder<'a> { pub struct TocBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
toc: &'a crate::Toc, 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> { pub struct ProtectionBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
system_id: &'a str, 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> { pub struct SegmentDoneBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
position: GenericFormattedValue, position: GenericFormattedValue,
@ -1965,6 +1981,7 @@ impl<'a> SegmentDoneBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct GapBuilder<'a> { pub struct GapBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
timestamp: ClockTime, timestamp: ClockTime,
@ -2012,6 +2029,7 @@ impl<'a> GapBuilder<'a> {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[must_use = "The builder must be built to be used"]
pub struct InstantRateChangeBuilder<'a> { pub struct InstantRateChangeBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
multiplier: f64, multiplier: f64,
@ -2036,6 +2054,7 @@ impl<'a> InstantRateChangeBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct QosBuilder<'a> { pub struct QosBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
type_: crate::QOSType, 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> { pub struct SeekBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
rate: f64, rate: f64,
@ -2131,6 +2151,7 @@ impl<'a> SeekBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct NavigationBuilder<'a> { pub struct NavigationBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
structure: Option<Structure>, structure: Option<Structure>,
@ -2151,6 +2172,7 @@ impl<'a> NavigationBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct LatencyBuilder<'a> { pub struct LatencyBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
latency: ClockTime, 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()) }); 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> { pub struct StepBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
amount: GenericFormattedValue, amount: GenericFormattedValue,
@ -2199,6 +2222,7 @@ impl<'a> StepBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct ReconfigureBuilder<'a> { pub struct ReconfigureBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
} }
@ -2214,6 +2238,7 @@ impl<'a> ReconfigureBuilder<'a> {
event_builder_generic_impl!(|_| { ffi::gst_event_new_reconfigure() }); event_builder_generic_impl!(|_| { ffi::gst_event_new_reconfigure() });
} }
#[must_use = "The builder must be built to be used"]
pub struct TocSelectBuilder<'a> { pub struct TocSelectBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
uid: &'a str, uid: &'a str,
@ -2235,6 +2260,7 @@ impl<'a> TocSelectBuilder<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[must_use = "The builder must be built to be used"]
pub struct SelectStreamsBuilder<'a> { pub struct SelectStreamsBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
streams: &'a [&'a str], 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> { pub struct CustomUpstreamBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
structure: Option<Structure>, structure: Option<Structure>,
@ -2276,6 +2303,7 @@ impl<'a> CustomUpstreamBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct CustomDownstreamBuilder<'a> { pub struct CustomDownstreamBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
structure: Option<Structure>, structure: Option<Structure>,
@ -2296,6 +2324,7 @@ impl<'a> CustomDownstreamBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct CustomDownstreamOobBuilder<'a> { pub struct CustomDownstreamOobBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
structure: Option<Structure>, structure: Option<Structure>,
@ -2316,6 +2345,7 @@ impl<'a> CustomDownstreamOobBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct CustomDownstreamStickyBuilder<'a> { pub struct CustomDownstreamStickyBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
structure: Option<Structure>, structure: Option<Structure>,
@ -2339,6 +2369,7 @@ impl<'a> CustomDownstreamStickyBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct CustomBothBuilder<'a> { pub struct CustomBothBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
structure: Option<Structure>, structure: Option<Structure>,
@ -2359,6 +2390,7 @@ impl<'a> CustomBothBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct CustomBothOobBuilder<'a> { pub struct CustomBothOobBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
structure: Option<Structure>, structure: Option<Structure>,

View file

@ -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 { pub fn build(mut self) -> Message {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { 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> { pub struct EosBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
} }
@ -1846,6 +1848,7 @@ impl MessageErrorDomain for crate::ResourceError {}
impl MessageErrorDomain for crate::StreamError {} impl MessageErrorDomain for crate::StreamError {}
impl MessageErrorDomain for crate::LibraryError {} impl MessageErrorDomain for crate::LibraryError {}
#[must_use = "The builder must be built to be used"]
pub struct ErrorBuilder<'a, T> { pub struct ErrorBuilder<'a, T> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
error: T, 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> { pub struct WarningBuilder<'a, T> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
error: T, 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> { pub struct InfoBuilder<'a, T> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
error: T, 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> { pub struct TagBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
tags: &'a TagList, 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> { pub struct BufferingBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
percent: i32, percent: i32,
@ -2111,6 +2118,7 @@ impl<'a> BufferingBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct StateChangedBuilder<'a> { pub struct StateChangedBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
old: crate::State, 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> { pub struct StateDirtyBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
} }
@ -2152,6 +2161,7 @@ impl<'a> StateDirtyBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_state_dirty(src)); 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> { pub struct StepDoneBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
amount: GenericFormattedValue, amount: GenericFormattedValue,
@ -2196,6 +2206,7 @@ impl<'a> StepDoneBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct ClockProvideBuilder<'a> { pub struct ClockProvideBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
clock: &'a crate::Clock, 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> { pub struct ClockLostBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
clock: &'a crate::Clock, 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> { pub struct NewClockBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
clock: &'a crate::Clock, 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> { pub struct StructureChangeBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
type_: crate::StructureChangeType, 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> { pub struct StreamStatusBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
type_: crate::StreamStatusType, 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> { pub struct ApplicationBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
structure: Option<crate::Structure>, structure: Option<crate::Structure>,
@ -2343,6 +2359,7 @@ impl<'a> ApplicationBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct ElementBuilder<'a> { pub struct ElementBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
structure: Option<crate::Structure>, structure: Option<crate::Structure>,
@ -2363,6 +2380,7 @@ impl<'a> ElementBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct SegmentStartBuilder<'a> { pub struct SegmentStartBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
position: GenericFormattedValue, position: GenericFormattedValue,
@ -2384,6 +2402,7 @@ impl<'a> SegmentStartBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct SegmentDoneBuilder<'a> { pub struct SegmentDoneBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
position: GenericFormattedValue, position: GenericFormattedValue,
@ -2405,6 +2424,7 @@ impl<'a> SegmentDoneBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct DurationChangedBuilder<'a> { pub struct DurationChangedBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
} }
@ -2420,6 +2440,7 @@ impl<'a> DurationChangedBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_duration_changed(src)); 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> { pub struct LatencyBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
} }
@ -2435,6 +2456,7 @@ impl<'a> LatencyBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_latency(src)); 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> { pub struct AsyncStartBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
} }
@ -2450,6 +2472,7 @@ impl<'a> AsyncStartBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_async_start(src)); 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> { pub struct AsyncDoneBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
running_time: Option<crate::ClockTime>, running_time: Option<crate::ClockTime>,
@ -2475,6 +2498,7 @@ impl<'a> AsyncDoneBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct RequestStateBuilder<'a> { pub struct RequestStateBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
state: crate::State, 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> { pub struct StepStartBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
active: bool, active: bool,
@ -2534,6 +2559,7 @@ impl<'a> StepStartBuilder<'a> {
)); ));
} }
#[must_use = "The builder must be built to be used"]
pub struct QosBuilder<'a> { pub struct QosBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
live: bool, live: bool,
@ -2621,6 +2647,7 @@ impl<'a> QosBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct ProgressBuilder<'a> { pub struct ProgressBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
type_: crate::ProgressType, 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> { pub struct TocBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
toc: &'a crate::Toc, 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> { pub struct ResetTimeBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
running_time: crate::ClockTime, 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> { pub struct StreamStartBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
group_id: Option<GroupId>, group_id: Option<GroupId>,
@ -2720,6 +2750,7 @@ impl<'a> StreamStartBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct NeedContextBuilder<'a> { pub struct NeedContextBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
context_type: &'a str, 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> { pub struct HaveContextBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
context: Option<crate::Context>, context: Option<crate::Context>,
@ -2760,6 +2792,7 @@ impl<'a> HaveContextBuilder<'a> {
}); });
} }
#[must_use = "The builder must be built to be used"]
pub struct DeviceAddedBuilder<'a> { pub struct DeviceAddedBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
device: &'a crate::Device, 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> { pub struct DeviceRemovedBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
device: &'a crate::Device, device: &'a crate::Device,
@ -2802,6 +2836,7 @@ impl<'a> DeviceRemovedBuilder<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[must_use = "The builder must be built to be used"]
pub struct PropertyNotifyBuilder<'a> { pub struct PropertyNotifyBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
property_name: &'a str, property_name: &'a str,
@ -2843,6 +2878,7 @@ impl<'a> PropertyNotifyBuilder<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[must_use = "The builder must be built to be used"]
pub struct StreamCollectionBuilder<'a> { pub struct StreamCollectionBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
collection: &'a crate::StreamCollection, collection: &'a crate::StreamCollection,
@ -2866,6 +2902,7 @@ impl<'a> StreamCollectionBuilder<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[must_use = "The builder must be built to be used"]
pub struct StreamsSelectedBuilder<'a> { pub struct StreamsSelectedBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -2908,6 +2945,7 @@ impl<'a> StreamsSelectedBuilder<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[must_use = "The builder must be built to be used"]
pub struct RedirectBuilder<'a> { pub struct RedirectBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
location: &'a str, location: &'a str,
@ -2992,6 +3030,7 @@ impl<'a> RedirectBuilder<'a> {
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
#[must_use = "The builder must be built to be used"]
pub struct DeviceChangedBuilder<'a> { pub struct DeviceChangedBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
device: &'a crate::Device, device: &'a crate::Device,
@ -3019,6 +3058,7 @@ impl<'a> DeviceChangedBuilder<'a> {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[must_use = "The builder must be built to be used"]
pub struct InstantRateRequestBuilder<'a> { pub struct InstantRateRequestBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
rate_multiplier: f64, rate_multiplier: f64,

View file

@ -1618,6 +1618,7 @@ impl Pad {
} }
} }
#[must_use = "The builder must be built to be used"]
pub struct PadBuilder<T>(pub(crate) T); pub struct PadBuilder<T>(pub(crate) T);
impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> { impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
@ -1847,6 +1848,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self self
} }
#[must_use = "Building the pad without using it has no effect"]
pub fn build(self) -> T { pub fn build(self) -> T {
self.0 self.0
} }

View file

@ -22,6 +22,7 @@ mini_object_wrapper!(Sample, SampleRef, ffi::GstSample, || {
}); });
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[must_use = "The builder must be built to be used"]
pub struct SampleBuilder<'a> { pub struct SampleBuilder<'a> {
buffer: Option<&'a Buffer>, buffer: Option<&'a Buffer>,
buffer_list: Option<&'a BufferList>, 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 { pub fn build(self) -> Sample {
assert_initialized_main_thread!(); assert_initialized_main_thread!();

View file

@ -67,6 +67,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
impl<'a> ExactSizeIterator for Iter<'a> {} impl<'a> ExactSizeIterator for Iter<'a> {}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[must_use = "The builder must be built to be used"]
pub struct StreamCollectionBuilder(StreamCollection); pub struct StreamCollectionBuilder(StreamCollection);
impl StreamCollectionBuilder { impl StreamCollectionBuilder {
@ -92,6 +93,7 @@ impl StreamCollectionBuilder {
self self
} }
#[must_use = "Building the stream collection without using it has no effect"]
pub fn build(self) -> StreamCollection { pub fn build(self) -> StreamCollection {
self.0 self.0
} }

View file

@ -864,6 +864,7 @@ impl std::iter::Extend<(glib::Quark, SendValue)> for StructureRef {
} }
#[derive(Debug)] #[derive(Debug)]
#[must_use = "The builder must be built to be used"]
pub struct Builder { pub struct Builder {
s: Structure, s: Structure,
} }
@ -881,6 +882,7 @@ impl Builder {
self self
} }
#[must_use = "Building the structure without using it has no effect"]
pub fn build(self) -> Structure { pub fn build(self) -> Structure {
self.s self.s
} }