1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::URIType;
7use glib::{prelude::*, translate::*};
8use std::ptr;
9
10glib::wrapper! {
11 #[doc(alias = "GstURIHandler")]
12 pub struct URIHandler(Interface<ffi::GstURIHandler, ffi::GstURIHandlerInterface>);
13
14 match fn {
15 type_ => || ffi::gst_uri_handler_get_type(),
16 }
17}
18
19impl URIHandler {
20 pub const NONE: Option<&'static URIHandler> = None;
21}
22
23unsafe impl Send for URIHandler {}
24unsafe impl Sync for URIHandler {}
25
26mod sealed {
27 pub trait Sealed {}
28 impl<T: super::IsA<super::URIHandler>> Sealed for T {}
29}
30
31pub trait URIHandlerExt: IsA<URIHandler> + sealed::Sealed + 'static {
32 #[doc(alias = "gst_uri_handler_get_protocols")]
33 #[doc(alias = "get_protocols")]
34 fn protocols(&self) -> Vec<glib::GString> {
35 unsafe {
36 FromGlibPtrContainer::from_glib_none(ffi::gst_uri_handler_get_protocols(
37 self.as_ref().to_glib_none().0,
38 ))
39 }
40 }
41
42 #[doc(alias = "gst_uri_handler_get_uri")]
43 #[doc(alias = "get_uri")]
44 fn uri(&self) -> Option<glib::GString> {
45 unsafe { from_glib_full(ffi::gst_uri_handler_get_uri(self.as_ref().to_glib_none().0)) }
46 }
47
48 #[doc(alias = "gst_uri_handler_get_uri_type")]
49 #[doc(alias = "get_uri_type")]
50 fn uri_type(&self) -> URIType {
51 unsafe {
52 from_glib(ffi::gst_uri_handler_get_uri_type(
53 self.as_ref().to_glib_none().0,
54 ))
55 }
56 }
57
58 #[doc(alias = "gst_uri_handler_set_uri")]
59 fn set_uri(&self, uri: &str) -> Result<(), glib::Error> {
60 unsafe {
61 let mut error = ptr::null_mut();
62 let is_ok = ffi::gst_uri_handler_set_uri(
63 self.as_ref().to_glib_none().0,
64 uri.to_glib_none().0,
65 &mut error,
66 );
67 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
68 if error.is_null() {
69 Ok(())
70 } else {
71 Err(from_glib_full(error))
72 }
73 }
74 }
75}
76
77impl<O: IsA<URIHandler>> URIHandlerExt for O {}
78