1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::{fmt, marker::PhantomData, ptr};
4
5use glib::{translate::*, StaticType};
6
7use crate::Caps;
8
9#[doc(alias = "GstStaticCaps")]
10#[derive(Clone, Copy)]
11pub struct StaticCaps(ptr::NonNull<ffi::GstStaticCaps>);
12
13impl StaticCaps {
14 #[doc(alias = "gst_static_caps_get")]
15 #[inline]
16 pub fn get(&self) -> Caps {
17 unsafe { from_glib_full(ptr:ffi::gst_static_caps_get(self.0.as_ptr())) }
18 }
19}
20
21unsafe impl Send for StaticCaps {}
22unsafe impl Sync for StaticCaps {}
23
24impl fmt::Debug for StaticCaps {
25 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
26 f&mut DebugStruct<'_, '_>.debug_struct("StaticCaps")
27 .field(name:"str", &unsafe {
28 glib::GStr::from_ptr(self.0.as_ref().string)
29 })
30 .finish()
31 }
32}
33
34impl glib::types::StaticType for StaticCaps {
35 #[inline]
36 fn static_type() -> glib::types::Type {
37 unsafe { glib::translate::from_glib(val:ffi::gst_static_caps_get_type()) }
38 }
39}
40
41impl glib::value::ValueType for StaticCaps {
42 type Type = Self;
43}
44
45unsafe impl glib::translate::TransparentPtrType for StaticCaps {}
46
47#[doc(hidden)]
48unsafe impl<'a> glib::value::FromValue<'a> for StaticCaps {
49 type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
50
51 #[inline]
52 unsafe fn from_value(value: &'a glib::Value) -> Self {
53 skip_assert_initialized!();
54 from_glib_none(
55 ptr:glib::gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *mut ffi::GstStaticCaps
56 )
57 }
58}
59
60#[doc(hidden)]
61impl glib::value::ToValue for StaticCaps {
62 #[inline]
63 fn to_value(&self) -> glib::Value {
64 let mut value: Value = glib::Value::for_value_type::<Self>();
65 unsafe {
66 glib::gobject_ffi::g_value_set_boxed(
67 value:value.to_glib_none_mut().0,
68 self.to_glib_none().0 as *mut _,
69 )
70 }
71 value
72 }
73
74 #[inline]
75 fn value_type(&self) -> glib::Type {
76 Self::static_type()
77 }
78}
79
80impl From<StaticCaps> for glib::Value {
81 #[inline]
82 fn from(v: StaticCaps) -> glib::Value {
83 skip_assert_initialized!();
84 glib::value::ToValue::to_value(&v)
85 }
86}
87
88#[doc(hidden)]
89impl glib::value::ToValueOptional for StaticCaps {
90 #[inline]
91 fn to_value_optional(s: Option<&Self>) -> glib::Value {
92 skip_assert_initialized!();
93 let mut value: Value = glib::Value::for_value_type::<Self>();
94 unsafe {
95 glib::gobject_ffi::g_value_set_boxed(
96 value:value.to_glib_none_mut().0,
97 v_boxed:s.to_glib_none().0 as *mut _,
98 )
99 }
100 value
101 }
102}
103
104#[doc(hidden)]
105impl glib::translate::GlibPtrDefault for StaticCaps {
106 type GlibType = *mut ffi::GstStaticCaps;
107}
108
109#[doc(hidden)]
110impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticCaps> for StaticCaps {
111 type Storage = PhantomData<&'a StaticCaps>;
112
113 #[inline]
114 fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstStaticCaps, Self> {
115 glib::translate::Stash(self.0.as_ptr(), PhantomData)
116 }
117
118 fn to_glib_full(&self) -> *const ffi::GstStaticCaps {
119 unimplemented!()
120 }
121}
122
123#[doc(hidden)]
124impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticCaps> for StaticCaps {
125 #[inline]
126 unsafe fn from_glib_none(ptr: *const ffi::GstStaticCaps) -> Self {
127 debug_assert!(!ptr.is_null());
128 StaticCaps(ptr::NonNull::new_unchecked(ptr as *mut _))
129 }
130}
131
132#[doc(hidden)]
133impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticCaps> for StaticCaps {
134 #[inline]
135 unsafe fn from_glib_none(ptr: *mut ffi::GstStaticCaps) -> Self {
136 debug_assert!(!ptr.is_null());
137 StaticCaps(ptr::NonNull::new_unchecked(ptr))
138 }
139}
140
141#[doc(hidden)]
142impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstStaticCaps> for StaticCaps {
143 #[inline]
144 unsafe fn from_glib_borrow(ptr: *mut ffi::GstStaticCaps) -> Borrowed<Self> {
145 debug_assert!(!ptr.is_null());
146 Borrowed::new(val:StaticCaps(ptr::NonNull::new_unchecked(ptr)))
147 }
148}
149
150#[doc(hidden)]
151impl glib::translate::FromGlibPtrFull<*mut ffi::GstStaticCaps> for StaticCaps {
152 #[inline]
153 unsafe fn from_glib_full(_ptr: *mut ffi::GstStaticCaps) -> Self {
154 unimplemented!();
155 }
156}
157