gstreamer: Add PartialEq impls between owned/borrowed miniobjects/structures

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1152>
This commit is contained in:
Sebastian Dröge 2022-11-21 11:11:24 +02:00
parent 56b9b66027
commit 1264eb10ac
6 changed files with 51 additions and 10 deletions

View file

@ -82,7 +82,7 @@ mod tests {
#[cfg(feature = "v1_18")]
{
use glib::translate::{from_glib_full, IntoGlib};
use glib::translate::IntoGlib;
/* audio_make_raw_caps() is a re-implementation so ensure it returns the same caps as the C API */
let c_caps = unsafe {
@ -96,7 +96,7 @@ mod tests {
formats.len() as u32,
ffi::GST_AUDIO_LAYOUT_INTERLEAVED,
);
from_glib_full(caps)
gst::Caps::from_glib_full(caps)
};
assert_eq!(caps, c_caps);
}

View file

@ -307,7 +307,7 @@ mod tests {
.map(|f| f.into_glib())
.collect();
let caps = ffi::gst_video_make_raw_caps(formats.as_ptr(), formats.len() as u32);
from_glib_full(caps)
gst::Caps::from_glib_full(caps)
};
assert_eq!(caps, c_caps);
}

View file

@ -1035,6 +1035,17 @@ impl PartialEq for Buffer {
impl Eq for Buffer {}
impl PartialEq<BufferRef> for Buffer {
fn eq(&self, other: &BufferRef) -> bool {
BufferRef::eq(self, other)
}
}
impl PartialEq<Buffer> for BufferRef {
fn eq(&self, other: &Buffer) -> bool {
BufferRef::eq(other, self)
}
}
impl fmt::Debug for BufferRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use crate::utils::Displayable;

View file

@ -827,6 +827,18 @@ impl PartialEq for Caps {
impl Eq for Caps {}
impl PartialEq<CapsRef> for Caps {
fn eq(&self, other: &CapsRef) -> bool {
CapsRef::eq(self, other)
}
}
impl PartialEq<Caps> for CapsRef {
fn eq(&self, other: &Caps) -> bool {
CapsRef::eq(other, self)
}
}
impl fmt::Debug for CapsRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.is_any() {

View file

@ -153,18 +153,24 @@ impl fmt::Display for Structure {
impl PartialEq for Structure {
fn eq(&self, other: &Structure) -> bool {
self.as_ref().eq(other)
}
}
impl PartialEq<StructureRef> for Structure {
fn eq(&self, other: &StructureRef) -> bool {
self.as_ref().eq(other)
StructureRef::eq(self, other)
}
}
impl Eq for Structure {}
impl PartialEq<StructureRef> for Structure {
fn eq(&self, other: &StructureRef) -> bool {
StructureRef::eq(self, other)
}
}
impl PartialEq<Structure> for StructureRef {
fn eq(&self, other: &Structure) -> bool {
StructureRef::eq(other, self)
}
}
impl str::FromStr for Structure {
type Err = glib::BoolError;

View file

@ -584,6 +584,18 @@ impl PartialEq for TagList {
impl Eq for TagList {}
impl PartialEq<TagListRef> for TagList {
fn eq(&self, other: &TagListRef) -> bool {
TagListRef::eq(self, other)
}
}
impl PartialEq<TagList> for TagListRef {
fn eq(&self, other: &TagList) -> bool {
TagListRef::eq(other, self)
}
}
impl fmt::Debug for TagListRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut debug = f.debug_struct("TagList");