diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 4eabc6dd6..5415c4f9c 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -873,27 +873,64 @@ declare_concrete_event!(CustomDownstreamSticky); declare_concrete_event!(CustomBoth); declare_concrete_event!(CustomBothOob); +struct EventBuilder<'a> { + seqnum: Option, + running_time_offset: Option, + other_fields: Vec<(&'a str, &'a ToSendValue)>, +} + +impl<'a> EventBuilder<'a> { + fn new() -> Self { + Self { + seqnum: None, + running_time_offset: None, + other_fields: Vec::new() + } + } + + fn seqnum(self, seqnum: Seqnum) -> Self { + Self { + seqnum: Some(seqnum), + .. self + } + } + + fn running_time_offset(self, running_time_offset: i64) -> Self { + Self { + running_time_offset: Some(running_time_offset), + .. self + } + } + + fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { + Self { + other_fields: self.other_fields.iter().cloned() + .chain(other_fields.iter().cloned()) + .collect(), + .. self + } + } +} + macro_rules! event_builder_generic_impl { ($new_fn:expr) => { pub fn seqnum(self, seqnum: Seqnum) -> Self { Self { - seqnum: Some(seqnum), + builder: self.builder.seqnum(seqnum), .. self } } pub fn running_time_offset(self, running_time_offset: i64) -> Self { Self { - running_time_offset: Some(running_time_offset), + builder: self.builder.running_time_offset(running_time_offset), .. self } } pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { Self { - other_fields: self.other_fields.iter().cloned() - .chain(other_fields.iter().cloned()) - .collect(), + builder: self.builder.other_fields(other_fields), .. self } } @@ -902,20 +939,20 @@ macro_rules! event_builder_generic_impl { assert_initialized_main_thread!(); unsafe { let event = $new_fn(&mut self); - if let Some(seqnum) = self.seqnum { + if let Some(seqnum) = self.builder.seqnum { ffi::gst_event_set_seqnum(event, seqnum.to_glib()); } - if let Some(running_time_offset) = self.running_time_offset { + if let Some(running_time_offset) = self.builder.running_time_offset { ffi::gst_event_set_running_time_offset(event, running_time_offset); } - if !self.other_fields.is_empty() { + if !self.builder.other_fields.is_empty() { let s = StructureRef::from_glib_borrow_mut( ffi::gst_event_writable_structure(event) ); - for (k, v) in self.other_fields { + for (k, v) in self.builder.other_fields { s.set_value(k, v.to_send_value()); } } @@ -927,17 +964,13 @@ macro_rules! event_builder_generic_impl { } pub struct FlushStartBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, } impl<'a> FlushStartBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), } } @@ -945,18 +978,14 @@ impl<'a> FlushStartBuilder<'a> { } pub struct FlushStopBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, reset_time: bool, } impl<'a> FlushStopBuilder<'a> { fn new(reset_time: bool) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), reset_time: reset_time, } } @@ -965,9 +994,7 @@ impl<'a> FlushStopBuilder<'a> { } pub struct StreamStartBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, stream_id: &'a str, flags: Option<::StreamFlags>, group_id: Option, @@ -976,9 +1003,7 @@ impl<'a> StreamStartBuilder<'a> { fn new(stream_id: &'a str) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), stream_id: stream_id, flags: None, group_id: None, @@ -1012,18 +1037,14 @@ impl<'a> StreamStartBuilder<'a> { } pub struct CapsBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, caps: &'a ::Caps, } impl<'a> CapsBuilder<'a> { fn new(caps: &'a ::Caps) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), caps: caps, } } @@ -1032,18 +1053,14 @@ impl<'a> CapsBuilder<'a> { } pub struct SegmentBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, segment: &'a ::Segment, } impl<'a> SegmentBuilder<'a> { fn new(segment: &'a ::Segment) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), segment: segment, } } @@ -1053,9 +1070,7 @@ impl<'a> SegmentBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] pub struct StreamCollectionBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, stream_collection: &'a ::StreamCollection, } #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -1063,9 +1078,7 @@ impl<'a> StreamCollectionBuilder<'a> { fn new(stream_collection: &'a ::StreamCollection) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), stream_collection: stream_collection, } } @@ -1076,18 +1089,14 @@ impl<'a> StreamCollectionBuilder<'a> { } pub struct TagBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, tags: Option<::TagList>, } impl<'a> TagBuilder<'a> { fn new(tags: ::TagList) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), tags: Some(tags), } } @@ -1099,9 +1108,7 @@ impl<'a> TagBuilder<'a> { } pub struct BufferSizeBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, minsize: GenericFormattedValue, maxsize: GenericFormattedValue, async: bool, @@ -1110,9 +1117,7 @@ impl<'a> BufferSizeBuilder<'a> { fn new(minsize: GenericFormattedValue, maxsize: GenericFormattedValue, async: bool) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), minsize: minsize, maxsize: maxsize, async: async, @@ -1128,9 +1133,7 @@ impl<'a> BufferSizeBuilder<'a> { } pub struct SinkMessageBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, name: &'a str, msg: &'a ::Message, } @@ -1138,9 +1141,7 @@ impl<'a> SinkMessageBuilder<'a> { fn new(name: &'a str, msg: &'a ::Message) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), name: name, msg: msg, } @@ -1154,9 +1155,7 @@ impl<'a> SinkMessageBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] pub struct StreamGroupDoneBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, group_id: GroupId, } #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -1164,9 +1163,7 @@ impl<'a> StreamGroupDoneBuilder<'a> { fn new(group_id: GroupId) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), group_id: group_id, } } @@ -1177,17 +1174,13 @@ impl<'a> StreamGroupDoneBuilder<'a> { } pub struct EosBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, } impl<'a> EosBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), } } @@ -1195,9 +1188,7 @@ impl<'a> EosBuilder<'a> { } pub struct TocBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, toc: &'a ::Toc, updated: bool, } @@ -1205,9 +1196,7 @@ impl<'a> TocBuilder<'a> { fn new(toc: &'a ::Toc, updated: bool) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), toc: toc, updated: updated, } @@ -1220,9 +1209,7 @@ impl<'a> TocBuilder<'a> { } pub struct ProtectionBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, system_id: &'a str, data: &'a ::Buffer, origin: Option<&'a str>, @@ -1231,9 +1218,7 @@ impl<'a> ProtectionBuilder<'a> { fn new(system_id: &'a str, data: &'a ::Buffer) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), system_id: system_id, data: data, origin: None, @@ -1255,18 +1240,14 @@ impl<'a> ProtectionBuilder<'a> { } pub struct SegmentDoneBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, position: GenericFormattedValue, } impl<'a> SegmentDoneBuilder<'a> { fn new(position: GenericFormattedValue) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), position: position, } } @@ -1278,9 +1259,7 @@ impl<'a> SegmentDoneBuilder<'a> { } pub struct GapBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, timestamp: ::ClockTime, duration: ::ClockTime, } @@ -1288,9 +1267,7 @@ impl<'a> GapBuilder<'a> { fn new(timestamp: ::ClockTime, duration: ::ClockTime) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), timestamp: timestamp, duration: duration, } @@ -1303,9 +1280,7 @@ impl<'a> GapBuilder<'a> { } pub struct QosBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, type_: ::QOSType, proportion: f64, diff: i64, @@ -1315,9 +1290,7 @@ impl<'a> QosBuilder<'a> { fn new(type_: ::QOSType, proportion: f64, diff: i64, timestamp: ::ClockTime) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), type_: type_, proportion: proportion, diff: diff, @@ -1334,9 +1307,7 @@ impl<'a> QosBuilder<'a> { } pub struct SeekBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, rate: f64, flags: ::SeekFlags, start_type: ::SeekType, @@ -1355,9 +1326,7 @@ impl<'a> SeekBuilder<'a> { ) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), rate: rate, flags: flags, start_type, @@ -1379,18 +1348,14 @@ impl<'a> SeekBuilder<'a> { } pub struct NavigationBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, structure: Option, } impl<'a> NavigationBuilder<'a> { fn new(structure: Structure) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), structure: Some(structure), } } @@ -1405,18 +1370,14 @@ impl<'a> NavigationBuilder<'a> { } pub struct LatencyBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, latency: ::ClockTime, } impl<'a> LatencyBuilder<'a> { fn new(latency: ::ClockTime) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), latency: latency, } } @@ -1425,9 +1386,7 @@ impl<'a> LatencyBuilder<'a> { } pub struct StepBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, amount: GenericFormattedValue, rate: f64, flush: bool, @@ -1437,9 +1396,7 @@ impl<'a> StepBuilder<'a> { fn new(amount: GenericFormattedValue, rate: f64, flush: bool, intermediate: bool) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), amount: amount, rate: rate, flush: flush, @@ -1457,17 +1414,13 @@ impl<'a> StepBuilder<'a> { } pub struct ReconfigureBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, } impl<'a> ReconfigureBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), } } @@ -1475,18 +1428,14 @@ impl<'a> ReconfigureBuilder<'a> { } pub struct TocSelectBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, uid: &'a str, } impl<'a> TocSelectBuilder<'a> { fn new(uid: &'a str) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), uid: uid, } } @@ -1496,9 +1445,7 @@ impl<'a> TocSelectBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] pub struct SelectStreamsBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, streams: &'a [&'a str], } #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -1506,9 +1453,7 @@ impl<'a> SelectStreamsBuilder<'a> { fn new(streams: &'a [&'a str]) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), streams: streams, } } @@ -1519,18 +1464,14 @@ impl<'a> SelectStreamsBuilder<'a> { } pub struct CustomUpstreamBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, structure: Option, } impl<'a> CustomUpstreamBuilder<'a> { fn new(structure: Structure) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), structure: Some(structure), } } @@ -1546,18 +1487,14 @@ impl<'a> CustomUpstreamBuilder<'a> { } pub struct CustomDownstreamBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, structure: Option, } impl<'a> CustomDownstreamBuilder<'a> { fn new(structure: Structure) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), structure: Some(structure), } } @@ -1573,18 +1510,14 @@ impl<'a> CustomDownstreamBuilder<'a> { } pub struct CustomDownstreamOobBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, structure: Option, } impl<'a> CustomDownstreamOobBuilder<'a> { fn new(structure: Structure) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), structure: Some(structure), } } @@ -1602,18 +1535,14 @@ impl<'a> CustomDownstreamOobBuilder<'a> { } pub struct CustomDownstreamStickyBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, structure: Option, } impl<'a> CustomDownstreamStickyBuilder<'a> { fn new(structure: Structure) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), structure: Some(structure), } } @@ -1631,18 +1560,14 @@ impl<'a> CustomDownstreamStickyBuilder<'a> { } pub struct CustomBothBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, structure: Option, } impl<'a> CustomBothBuilder<'a> { fn new(structure: Structure) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), structure: Some(structure), } } @@ -1657,18 +1582,14 @@ impl<'a> CustomBothBuilder<'a> { } pub struct CustomBothOobBuilder<'a> { - seqnum: Option, - running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: EventBuilder<'a>, structure: Option, } impl<'a> CustomBothOobBuilder<'a> { fn new(structure: Structure) -> Self { skip_assert_initialized!(); Self { - seqnum: None, - running_time_offset: None, - other_fields: Vec::new(), + builder: EventBuilder::new(), structure: Some(structure), } } @@ -1682,6 +1603,7 @@ impl<'a> CustomBothOobBuilder<'a> { ev }); } + #[cfg(test)] mod tests { use super::*; diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 18899be17..c4fcd47c1 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -1160,21 +1160,61 @@ impl<'a> Redirect<'a> { } } +struct MessageBuilder<'a> { + src: Option, + seqnum: Option, + other_fields: Vec<(&'a str, &'a ToSendValue)>, +} + +impl<'a> MessageBuilder<'a> { + fn new() -> Self { + Self { + src: None, + seqnum: None, + other_fields: Vec::new() + } + } + + pub fn src + Cast + Clone>(self, src: Option<&O>) -> Self { + Self { + src: src.map(|o| { + let o = (*o).clone(); + o.upcast::() + }), + .. self + } + } + + fn seqnum(self, seqnum: Seqnum) -> Self { + Self { + seqnum: Some(seqnum), + .. self + } + } + + // TODO: restore clone_and_chain_other_fields method and condition it to the "v1_14" feature + /*fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { + Self { + other_fields: self.other_fields.iter().cloned() + .chain(other_fields.iter().cloned()) + .collect(), + .. self + } + }*/ +} + macro_rules! message_builder_generic_impl { ($new_fn:expr) => { pub fn src + Cast + Clone>(self, src: Option<&O>) -> Self { Self { - src: src.map(|o| { - let o = (*o).clone(); - o.upcast::() - }), + builder: self.builder.src(src), .. self } } pub fn seqnum(self, seqnum: Seqnum) -> Self { Self { - seqnum: Some(seqnum), + builder: self.builder.seqnum(seqnum), .. self } } @@ -1182,9 +1222,7 @@ macro_rules! message_builder_generic_impl { // TODO: restore other_fields method and condition it to the "v1_14" feature /*pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { Self { - other_fields: self.other_fields.iter().cloned() - .chain(other_fields.iter().cloned()) - .collect(), + builder: self.builder.other_fields(other_fields), .. self } }*/ @@ -1192,13 +1230,13 @@ macro_rules! message_builder_generic_impl { pub fn build(mut self) -> Message { assert_initialized_main_thread!(); unsafe { - let src = self.src.to_glib_none().0; + let src = self.builder.src.to_glib_none().0; let msg = $new_fn(&mut self, src); - if let Some(seqnum) = self.seqnum { + if let Some(seqnum) = self.builder.seqnum { ffi::gst_message_set_seqnum(msg, seqnum.to_glib()); } - if !self.other_fields.is_empty() { + if !self.builder.other_fields.is_empty() { // issue with argument-less messages. We need the function // ffi::gst_message_writable_structure to sort this out // and this function will be available in GStreamer 1.14 @@ -1208,7 +1246,7 @@ macro_rules! message_builder_generic_impl { if !structure.is_null() { let structure = StructureRef::from_glib_borrow_mut(structure as *mut _); - for (k, v) in self.other_fields { + for (k, v) in self.builder.other_fields { structure.set_value(k, v.to_send_value()); } } @@ -1221,17 +1259,13 @@ macro_rules! message_builder_generic_impl { } pub struct EosBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, } impl<'a> EosBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), } } @@ -1246,9 +1280,7 @@ impl MessageErrorDomain for ::StreamError {} impl MessageErrorDomain for ::LibraryError {} pub struct ErrorBuilder<'a, T> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, error: T, message: &'a str, debug: Option<&'a str>, @@ -1258,9 +1290,7 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> { fn new(error: T, message: &'a str) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), error: error, message: message, debug: None, @@ -1314,9 +1344,7 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> { } pub struct WarningBuilder<'a, T> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, error: T, message: &'a str, debug: Option<&'a str>, @@ -1326,9 +1354,7 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> { fn new(error: T, message: &'a str) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), error: error, message: message, debug: None, @@ -1382,9 +1408,7 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> { } pub struct InfoBuilder<'a, T> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, error: T, message: &'a str, debug: Option<&'a str>, @@ -1394,9 +1418,7 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> { fn new(error: T, message: &'a str) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), error: error, message: message, debug: None, @@ -1450,18 +1472,14 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> { } pub struct TagBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, tags: &'a TagList, } impl<'a> TagBuilder<'a> { fn new(tags: &'a TagList) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), tags: tags, } } @@ -1473,9 +1491,7 @@ impl<'a> TagBuilder<'a> { } pub struct BufferingBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, percent: i32, stats: Option<(::BufferingMode, i32, i32, i64)>, } @@ -1483,9 +1499,7 @@ impl<'a> BufferingBuilder<'a> { fn new(percent: i32) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), percent: percent, stats: None, } @@ -1523,9 +1537,7 @@ impl<'a> BufferingBuilder<'a> { } pub struct StateChangedBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, old: ::State, new: ::State, pending: ::State, @@ -1534,9 +1546,7 @@ impl<'a> StateChangedBuilder<'a> { fn new(old: ::State, new: ::State, pending: ::State) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), old: old, new: new, pending: pending, @@ -1552,17 +1562,13 @@ impl<'a> StateChangedBuilder<'a> { } pub struct StateDirtyBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, } impl<'a> StateDirtyBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), } } @@ -1570,9 +1576,7 @@ impl<'a> StateDirtyBuilder<'a> { } pub struct StepDoneBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, amount: GenericFormattedValue, rate: f64, flush: bool, @@ -1592,9 +1596,7 @@ impl<'a> StepDoneBuilder<'a> { skip_assert_initialized!(); assert_eq!(amount.get_format(), duration.get_format()); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), amount: amount, rate: rate, flush: flush, @@ -1617,9 +1619,7 @@ impl<'a> StepDoneBuilder<'a> { } pub struct ClockProvideBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, clock: &'a ::Clock, ready: bool, } @@ -1627,9 +1627,7 @@ impl<'a> ClockProvideBuilder<'a> { fn new(clock: &'a ::Clock, ready: bool) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), clock: clock, ready: ready, } @@ -1643,18 +1641,14 @@ impl<'a> ClockProvideBuilder<'a> { } pub struct ClockLostBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, clock: &'a ::Clock, } impl<'a> ClockLostBuilder<'a> { fn new(clock: &'a ::Clock) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), clock: clock, } } @@ -1666,18 +1660,14 @@ impl<'a> ClockLostBuilder<'a> { } pub struct NewClockBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, clock: &'a ::Clock, } impl<'a> NewClockBuilder<'a> { fn new(clock: &'a ::Clock) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), clock: clock, } } @@ -1689,9 +1679,7 @@ impl<'a> NewClockBuilder<'a> { } pub struct StructureChangeBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, type_: ::StructureChangeType, owner: &'a ::Element, busy: bool, @@ -1700,9 +1688,7 @@ impl<'a> StructureChangeBuilder<'a> { fn new(type_: ::StructureChangeType, owner: &'a ::Element, busy: bool) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), type_: type_, owner: owner, busy: busy, @@ -1718,9 +1704,7 @@ impl<'a> StructureChangeBuilder<'a> { } pub struct StreamStatusBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, type_: ::StreamStatusType, owner: &'a ::Element, status_object: Option<&'a glib::ToSendValue>, @@ -1729,9 +1713,7 @@ impl<'a> StreamStatusBuilder<'a> { fn new(type_: ::StreamStatusType, owner: &'a ::Element) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), type_: type_, owner: owner, status_object: None, @@ -1759,18 +1741,14 @@ impl<'a> StreamStatusBuilder<'a> { } pub struct ApplicationBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, structure: Option<::Structure>, } impl<'a> ApplicationBuilder<'a> { fn new(structure: ::Structure) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), structure: Some(structure), } } @@ -1782,18 +1760,14 @@ impl<'a> ApplicationBuilder<'a> { } pub struct ElementBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, structure: Option<::Structure>, } impl<'a> ElementBuilder<'a> { fn new(structure: ::Structure) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), structure: Some(structure), } } @@ -1805,18 +1779,14 @@ impl<'a> ElementBuilder<'a> { } pub struct SegmentStartBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, position: GenericFormattedValue, } impl<'a> SegmentStartBuilder<'a> { fn new(position: GenericFormattedValue) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), position: position, } } @@ -1829,18 +1799,14 @@ impl<'a> SegmentStartBuilder<'a> { } pub struct SegmentDoneBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, position: GenericFormattedValue, } impl<'a> SegmentDoneBuilder<'a> { fn new(position: GenericFormattedValue) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), position: position, } } @@ -1853,17 +1819,13 @@ impl<'a> SegmentDoneBuilder<'a> { } pub struct DurationChangedBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, } impl<'a> DurationChangedBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), } } @@ -1871,17 +1833,13 @@ impl<'a> DurationChangedBuilder<'a> { } pub struct LatencyBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, } impl<'a> LatencyBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), } } @@ -1889,17 +1847,13 @@ impl<'a> LatencyBuilder<'a> { } pub struct AsyncStartBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, } impl<'a> AsyncStartBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), } } @@ -1907,18 +1861,14 @@ impl<'a> AsyncStartBuilder<'a> { } pub struct AsyncDoneBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, running_time: ::ClockTime, } impl<'a> AsyncDoneBuilder<'a> { fn new(running_time: ::ClockTime) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), running_time: running_time, } } @@ -1930,18 +1880,14 @@ impl<'a> AsyncDoneBuilder<'a> { } pub struct RequestStateBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, state: ::State, } impl<'a> RequestStateBuilder<'a> { fn new(state: ::State) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), state: state, } } @@ -1953,9 +1899,7 @@ impl<'a> RequestStateBuilder<'a> { } pub struct StepStartBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, active: bool, amount: GenericFormattedValue, rate: f64, @@ -1972,9 +1916,7 @@ impl<'a> StepStartBuilder<'a> { ) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), active: active, amount: amount, rate: rate, @@ -1995,9 +1937,7 @@ impl<'a> StepStartBuilder<'a> { } pub struct QosBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, live: bool, running_time: ::ClockTime, stream_time: ::ClockTime, @@ -2016,9 +1956,7 @@ impl<'a> QosBuilder<'a> { ) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), live: live, running_time: running_time, stream_time: stream_time, @@ -2071,9 +2009,7 @@ impl<'a> QosBuilder<'a> { } pub struct ProgressBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, type_: ::ProgressType, code: &'a str, text: &'a str, @@ -2082,9 +2018,7 @@ impl<'a> ProgressBuilder<'a> { fn new(type_: ::ProgressType, code: &'a str, text: &'a str) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), type_: type_, code: code, text: text, @@ -2100,9 +2034,7 @@ impl<'a> ProgressBuilder<'a> { } pub struct TocBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, toc: &'a ::Toc, updated: bool, } @@ -2110,9 +2042,7 @@ impl<'a> TocBuilder<'a> { fn new(toc: &'a ::Toc, updated: bool) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), toc: toc, updated: updated, } @@ -2126,18 +2056,14 @@ impl<'a> TocBuilder<'a> { } pub struct ResetTimeBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, running_time: ::ClockTime, } impl<'a> ResetTimeBuilder<'a> { fn new(running_time: ::ClockTime) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), running_time: running_time, } } @@ -2149,18 +2075,14 @@ impl<'a> ResetTimeBuilder<'a> { } pub struct StreamStartBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, group_id: Option, } impl<'a> StreamStartBuilder<'a> { fn new() -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), group_id: None, } } @@ -2182,18 +2104,14 @@ impl<'a> StreamStartBuilder<'a> { } pub struct NeedContextBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, context_type: &'a str, } impl<'a> NeedContextBuilder<'a> { fn new(context_type: &'a str) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), context_type: context_type, } } @@ -2205,18 +2123,14 @@ impl<'a> NeedContextBuilder<'a> { } pub struct HaveContextBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, context: Option<::Context>, } impl<'a> HaveContextBuilder<'a> { fn new(context: ::Context) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), context: Some(context), } } @@ -2228,18 +2142,14 @@ impl<'a> HaveContextBuilder<'a> { } pub struct DeviceAddedBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, device: &'a ::Device, } impl<'a> DeviceAddedBuilder<'a> { fn new(device: &'a ::Device) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), device: device, } } @@ -2251,18 +2161,14 @@ impl<'a> DeviceAddedBuilder<'a> { } pub struct DeviceRemovedBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, device: &'a ::Device, } impl<'a> DeviceRemovedBuilder<'a> { fn new(device: &'a ::Device) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), device: device, } } @@ -2275,9 +2181,7 @@ impl<'a> DeviceRemovedBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] pub struct PropertyNotifyBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, property_name: &'a str, value: Option<&'a glib::ToSendValue>, } @@ -2286,9 +2190,7 @@ impl<'a> PropertyNotifyBuilder<'a> { fn new(property_name: &'a str) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), property_name: property_name, value: None, } @@ -2317,9 +2219,7 @@ impl<'a> PropertyNotifyBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] pub struct StreamCollectionBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, collection: &'a ::StreamCollection, } #[cfg(any(feature = "v1_10", feature = "dox"))] @@ -2327,9 +2227,7 @@ impl<'a> StreamCollectionBuilder<'a> { fn new(collection: &'a ::StreamCollection) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), collection: collection, } } @@ -2342,9 +2240,7 @@ impl<'a> StreamCollectionBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] pub struct StreamsSelectedBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, #[cfg(any(feature = "v1_10", feature = "dox"))] collection: &'a ::StreamCollection, #[cfg(any(feature = "v1_10", feature = "dox"))] streams: Option<&'a [&'a ::Stream]>, } @@ -2353,9 +2249,7 @@ impl<'a> StreamsSelectedBuilder<'a> { fn new(collection: &'a ::StreamCollection) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), collection: collection, streams: None, } @@ -2381,9 +2275,7 @@ impl<'a> StreamsSelectedBuilder<'a> { #[cfg(any(feature = "v1_10", feature = "dox"))] pub struct RedirectBuilder<'a> { - src: Option, - seqnum: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + builder: MessageBuilder<'a>, location: &'a str, tag_list: Option<&'a TagList>, entry_struct: Option, @@ -2395,9 +2287,7 @@ impl<'a> RedirectBuilder<'a> { fn new(location: &'a str) -> Self { skip_assert_initialized!(); Self { - src: None, - seqnum: None, - other_fields: Vec::new(), + builder: MessageBuilder::new(), location: location, tag_list: None, entry_struct: None,