1use std::ptr;
4
5use glib::{prelude::*, translate::*};
6
7use crate::ChildProxy;
8
9mod sealed {
10 pub trait Sealed {}
11 impl<T: super::IsA<super::ChildProxy>> Sealed for T {}
12}
13
14pub trait ChildProxyExtManual: sealed::Sealed + IsA<ChildProxy> + 'static {
15 #[doc(alias = "gst_child_proxy_lookup")]
33 fn lookup(&self, name: &str) -> Result<(glib::Object, glib::ParamSpec), glib::BoolError> {
34 unsafe {
35 let mut target = ptr::null_mut();
36 let mut pspec = ptr::null_mut();
37 let ret = from_glib(crate::ffi::gst_child_proxy_lookup(
38 self.as_ref().to_glib_none().0,
39 name.to_glib_none().0,
40 &mut target,
41 &mut pspec,
42 ));
43 if ret {
44 Ok((from_glib_full(target), from_glib_none(pspec)))
45 } else {
46 Err(glib::bool_error!("Failed to find child property '{name}'"))
47 }
48 }
49 }
50
51 #[doc(alias = "get_child_property")]
62 #[doc(alias = "gst_child_proxy_get")]
63 #[track_caller]
64 fn child_property<V: for<'b> glib::value::FromValue<'b> + 'static>(&self, name: &str) -> V {
65 let (child, pspec) = self.lookup(name).unwrap();
66 child.property(pspec.name())
67 }
68
69 #[doc(alias = "get_child_property")]
70 #[doc(alias = "gst_child_proxy_get")]
71 #[track_caller]
72 fn child_property_value(&self, name: &str) -> glib::Value {
73 let (child, pspec) = self.lookup(name).unwrap();
74 child.property_value(pspec.name())
75 }
76
77 #[doc(alias = "gst_child_proxy_set")]
83 #[track_caller]
84 fn set_child_property(&self, name: &str, value: impl Into<glib::Value>) {
85 let (child, pspec) = self.lookup(name).unwrap();
86 child.set_property(pspec.name(), value)
87 }
88
89 #[doc(alias = "gst_child_proxy_set_property")]
90 #[track_caller]
91 fn set_child_property_from_value(&self, name: &str, value: &glib::Value) {
92 let (child, pspec) = self.lookup(name).unwrap();
93 child.set_property_from_value(pspec.name(), value)
94 }
95}
96
97impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {}