Add Eq/PartialEq instances for TagList and Caps

This commit is contained in:
Sebastian Dröge 2017-01-23 18:31:51 +02:00
parent 1ee7c8b9e3
commit 2ec438e5b8
2 changed files with 23 additions and 0 deletions

View file

@ -21,7 +21,9 @@ use std::ffi::CString;
use std::ffi::CStr;
use std::fmt;
use value::*;
use utils::*;
#[derive(Eq)]
pub struct Caps(*mut c_void);
impl Caps {
@ -163,6 +165,16 @@ impl fmt::Debug for Caps {
}
}
impl PartialEq for Caps {
fn eq(&self, other: &Caps) -> bool {
extern "C" {
fn gst_caps_is_equal(a: *const c_void, b: *const c_void) -> GBoolean;
}
unsafe { gst_caps_is_equal(self.0, other.0).to_bool() }
}
}
#[cfg(test)]
mod tests {
use super::*;

View file

@ -62,6 +62,7 @@ pub enum MergeMode {
KeepAll,
}
#[derive(Eq)]
pub struct TagList(*mut c_void);
impl TagList {
@ -193,6 +194,16 @@ impl fmt::Debug for TagList {
}
}
impl PartialEq for TagList {
fn eq(&self, other: &TagList) -> bool {
extern "C" {
fn gst_tag_list_is_equal(a: *const c_void, b: *const c_void) -> GBoolean;
}
unsafe { gst_tag_list_is_equal(self.0, other.0).to_bool() }
}
}
#[cfg(test)]
mod tests {
use super::*;