urihandler: Provide URIType as associated constant when implementing the gst::URIHandler interface

The supported protocols still stay a function because they might have to
be probed at runtime, but they return a static string array now as they
must not randomly change at runtime.
This commit is contained in:
Sebastian Dröge 2020-10-24 20:10:13 +03:00
parent ea0eb4fa70
commit 0e8b95f1d0

View file

@ -9,10 +9,10 @@ use crate::URIHandler;
use crate::URIType; use crate::URIType;
pub trait URIHandlerImpl: super::element::ElementImpl { pub trait URIHandlerImpl: super::element::ElementImpl {
const URI_TYPE: URIType;
fn get_protocols() -> &'static [&'static str];
fn get_uri(&self, element: &Self::Type) -> Option<String>; fn get_uri(&self, element: &Self::Type) -> Option<String>;
fn set_uri(&self, element: &Self::Type, uri: &str) -> Result<(), glib::Error>; fn set_uri(&self, element: &Self::Type, uri: &str) -> Result<(), glib::Error>;
fn get_uri_type() -> URIType;
fn get_protocols() -> Vec<String>;
} }
unsafe impl<T: URIHandlerImpl> IsImplementable<T> for URIHandler { unsafe impl<T: URIHandlerImpl> IsImplementable<T> for URIHandler {
@ -43,7 +43,7 @@ unsafe impl<T: URIHandlerImpl> IsImplementable<T> for URIHandler {
unsafe extern "C" fn uri_handler_get_type<T: URIHandlerImpl>( unsafe extern "C" fn uri_handler_get_type<T: URIHandlerImpl>(
_type_: glib::ffi::GType, _type_: glib::ffi::GType,
) -> ffi::GstURIType { ) -> ffi::GstURIType {
<T as URIHandlerImpl>::get_uri_type().to_glib() <T as URIHandlerImpl>::URI_TYPE.to_glib()
} }
unsafe extern "C" fn uri_handler_get_protocols<T: URIHandlerImpl>( unsafe extern "C" fn uri_handler_get_protocols<T: URIHandlerImpl>(