mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-19 00:26:29 +00:00
Use Option<&str> instead of &Option<&str> for set_uri()
This seems more ergonomic to use, and is more common in other libraries.
This commit is contained in:
parent
b8a031c29b
commit
acc7d2ea26
5 changed files with 12 additions and 12 deletions
|
@ -50,8 +50,8 @@ impl FileSink {
|
|||
}
|
||||
|
||||
impl Sink for FileSink {
|
||||
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool {
|
||||
match *uri_str {
|
||||
fn set_uri(&mut self, uri_str: Option<&str>) -> bool {
|
||||
match uri_str {
|
||||
None => {
|
||||
self.location = None;
|
||||
return true;
|
||||
|
|
|
@ -51,8 +51,8 @@ impl FileSrc {
|
|||
}
|
||||
|
||||
impl Source for FileSrc {
|
||||
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool {
|
||||
match *uri_str {
|
||||
fn set_uri(&mut self, uri_str: Option<&str>) -> bool {
|
||||
match uri_str {
|
||||
None => {
|
||||
self.location = None;
|
||||
return true;
|
||||
|
|
|
@ -123,13 +123,13 @@ impl HttpSrc {
|
|||
}
|
||||
|
||||
impl Source for HttpSrc {
|
||||
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool {
|
||||
fn set_uri(&mut self, uri_str: Option<&str>) -> bool {
|
||||
if self.response.is_some() {
|
||||
println_err!("Can't set URI after starting");
|
||||
return false;
|
||||
}
|
||||
|
||||
match *uri_str {
|
||||
match uri_str {
|
||||
None => {
|
||||
self.url = None;
|
||||
return true;
|
||||
|
|
|
@ -24,7 +24,7 @@ use std::ptr;
|
|||
use utils::*;
|
||||
|
||||
pub trait Sink: Sync + Send {
|
||||
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool;
|
||||
fn set_uri(&mut self, uri_str: Option<&str>) -> bool;
|
||||
fn get_uri(&self) -> Option<String>;
|
||||
fn start(&mut self) -> bool;
|
||||
fn stop(&mut self) -> bool;
|
||||
|
@ -41,10 +41,10 @@ pub extern "C" fn sink_set_uri(ptr: *mut Box<Sink>, uri_ptr: *const c_char) -> G
|
|||
let source: &mut Box<Sink> = unsafe { &mut *ptr };
|
||||
|
||||
if uri_ptr.is_null() {
|
||||
GBoolean::from_bool(source.set_uri(&None))
|
||||
GBoolean::from_bool(source.set_uri(None))
|
||||
} else {
|
||||
let uri = unsafe { CStr::from_ptr(uri_ptr) };
|
||||
GBoolean::from_bool(source.set_uri(&Some(uri.to_str().unwrap())))
|
||||
GBoolean::from_bool(source.set_uri(Some(uri.to_str().unwrap())))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::ptr;
|
|||
use utils::*;
|
||||
|
||||
pub trait Source: Sync + Send {
|
||||
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool;
|
||||
fn set_uri(&mut self, uri_str: Option<&str>) -> bool;
|
||||
fn get_uri(&self) -> Option<String>;
|
||||
fn is_seekable(&self) -> bool;
|
||||
fn get_size(&self) -> u64;
|
||||
|
@ -45,10 +45,10 @@ pub extern "C" fn source_set_uri(ptr: *mut Box<Source>, uri_ptr: *const c_char)
|
|||
let source: &mut Box<Source> = unsafe { &mut *ptr };
|
||||
|
||||
if uri_ptr.is_null() {
|
||||
GBoolean::from_bool(source.set_uri(&None))
|
||||
GBoolean::from_bool(source.set_uri(None))
|
||||
} else {
|
||||
let uri = unsafe { CStr::from_ptr(uri_ptr) };
|
||||
GBoolean::from_bool(source.set_uri(&Some(uri.to_str().unwrap())))
|
||||
GBoolean::from_bool(source.set_uri(Some(uri.to_str().unwrap())))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue