Remove PAD_PROBE_ID_INVALID and Default impls for PadProbeId and NotifyWatchId

These should never ever be 0, and passing 0 to any of the functions
using them will result in assertions.
This commit is contained in:
Sebastian Dröge 2018-01-25 21:06:39 +02:00
parent fc4ad81777
commit ad219dd171
3 changed files with 5 additions and 4 deletions

View file

@ -65,7 +65,7 @@ pub enum ElementMessageType {
Info, Info,
} }
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct NotifyWatchId(libc::c_ulong); pub struct NotifyWatchId(libc::c_ulong);
impl ToGlib for NotifyWatchId { impl ToGlib for NotifyWatchId {
@ -79,6 +79,7 @@ impl ToGlib for NotifyWatchId {
impl FromGlib<libc::c_ulong> for NotifyWatchId { impl FromGlib<libc::c_ulong> for NotifyWatchId {
fn from_glib(val: libc::c_ulong) -> NotifyWatchId { fn from_glib(val: libc::c_ulong) -> NotifyWatchId {
skip_assert_initialized!(); skip_assert_initialized!();
assert_ne!(val, 0);
NotifyWatchId(val) NotifyWatchId(val)
} }
} }

View file

@ -115,7 +115,7 @@ pub use element::{ElementExtManual, ElementMessageType, NotifyWatchId};
pub use element::{ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION, ELEMENT_METADATA_DOC_URI, pub use element::{ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION, ELEMENT_METADATA_DOC_URI,
ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS, ELEMENT_METADATA_LONGNAME}; ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS, ELEMENT_METADATA_LONGNAME};
pub use bin::BinExtManual; pub use bin::BinExtManual;
pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo, PAD_PROBE_ID_INVALID}; pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo};
pub use gobject::GObjectExtManualGst; pub use gobject::GObjectExtManualGst;
pub use child_proxy::ChildProxyExtManual; pub use child_proxy::ChildProxyExtManual;
pub use tag_setter::TagSetterExtManual; pub use tag_setter::TagSetterExtManual;

View file

@ -56,9 +56,8 @@ impl Pad {
} }
} }
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct PadProbeId(libc::c_ulong); pub struct PadProbeId(libc::c_ulong);
pub const PAD_PROBE_ID_INVALID: PadProbeId = PadProbeId(0);
impl ToGlib for PadProbeId { impl ToGlib for PadProbeId {
type GlibType = libc::c_ulong; type GlibType = libc::c_ulong;
@ -71,6 +70,7 @@ impl ToGlib for PadProbeId {
impl FromGlib<libc::c_ulong> for PadProbeId { impl FromGlib<libc::c_ulong> for PadProbeId {
fn from_glib(val: libc::c_ulong) -> PadProbeId { fn from_glib(val: libc::c_ulong) -> PadProbeId {
skip_assert_initialized!(); skip_assert_initialized!();
assert_ne!(val, 0);
PadProbeId(val) PadProbeId(val)
} }
} }