gstreamer/auto/
uri_handler.rs

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::{ffi, URIType};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    #[doc(alias = "GstURIHandler")]
11    pub struct URIHandler(Interface<ffi::GstURIHandler, ffi::GstURIHandlerInterface>);
12
13    match fn {
14        type_ => || ffi::gst_uri_handler_get_type(),
15    }
16}
17
18impl URIHandler {
19    pub const NONE: Option<&'static URIHandler> = None;
20}
21
22unsafe impl Send for URIHandler {}
23unsafe impl Sync for URIHandler {}
24
25pub trait URIHandlerExt: IsA<URIHandler> + 'static {
26    #[doc(alias = "gst_uri_handler_get_protocols")]
27    #[doc(alias = "get_protocols")]
28    fn protocols(&self) -> Vec<glib::GString> {
29        unsafe {
30            FromGlibPtrContainer::from_glib_none(ffi::gst_uri_handler_get_protocols(
31                self.as_ref().to_glib_none().0,
32            ))
33        }
34    }
35
36    #[doc(alias = "gst_uri_handler_get_uri")]
37    #[doc(alias = "get_uri")]
38    fn uri(&self) -> Option<glib::GString> {
39        unsafe { from_glib_full(ffi::gst_uri_handler_get_uri(self.as_ref().to_glib_none().0)) }
40    }
41
42    #[doc(alias = "gst_uri_handler_get_uri_type")]
43    #[doc(alias = "get_uri_type")]
44    fn uri_type(&self) -> URIType {
45        unsafe {
46            from_glib(ffi::gst_uri_handler_get_uri_type(
47                self.as_ref().to_glib_none().0,
48            ))
49        }
50    }
51
52    #[doc(alias = "gst_uri_handler_set_uri")]
53    fn set_uri(&self, uri: &str) -> Result<(), glib::Error> {
54        unsafe {
55            let mut error = std::ptr::null_mut();
56            let is_ok = ffi::gst_uri_handler_set_uri(
57                self.as_ref().to_glib_none().0,
58                uri.to_glib_none().0,
59                &mut error,
60            );
61            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
62            if error.is_null() {
63                Ok(())
64            } else {
65                Err(from_glib_full(error))
66            }
67        }
68    }
69}
70
71impl<O: IsA<URIHandler>> URIHandlerExt for O {}