gstreamer: Simplify MetaAPIExt trait implementation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1325>
This commit is contained in:
Sebastian Dröge 2023-10-16 15:19:52 +03:00
parent 62f58620b7
commit 5312131069

View file

@ -17,20 +17,8 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
} }
pub trait MetaAPIExt: MetaAPI { pub trait MetaAPIExt: MetaAPI {
#[inline]
#[doc(alias = "gst_meta_api_type_has_tag")] #[doc(alias = "gst_meta_api_type_has_tag")]
fn has_tag(&self, tag: glib::Quark) -> bool;
#[doc(alias = "gst_meta_api_type_get_tags")]
fn tags(&self) -> &[glib::GStringPtr];
unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef<Self>;
unsafe fn from_mut_ptr<T>(
buffer: &mut BufferRef,
ptr: *mut Self::GstType,
) -> MetaRefMut<Self, T>;
}
impl<A: MetaAPI> MetaAPIExt for A {
fn has_tag(&self, tag: glib::Quark) -> bool { fn has_tag(&self, tag: glib::Quark) -> bool {
unsafe { unsafe {
from_glib(ffi::gst_meta_api_type_has_tag( from_glib(ffi::gst_meta_api_type_has_tag(
@ -40,6 +28,8 @@ impl<A: MetaAPI> MetaAPIExt for A {
} }
} }
#[inline]
#[doc(alias = "gst_meta_api_type_get_tags")]
fn tags(&self) -> &[glib::GStringPtr] { fn tags(&self) -> &[glib::GStringPtr] {
unsafe { unsafe {
glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags( glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags(
@ -89,6 +79,8 @@ impl<A: MetaAPI> MetaAPIExt for A {
} }
} }
impl<A: MetaAPI> MetaAPIExt for A {}
#[cfg(feature = "v1_16")] #[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]