mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-09-27 14:30:27 +00:00
Use Option<&str> instead of Option<String> for set_uri()
There is no reason to require a heap-allocated String here.
This commit is contained in:
parent
546d67fa5a
commit
b8a031c29b
5 changed files with 10 additions and 10 deletions
|
@ -50,14 +50,14 @@ impl FileSink {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sink for FileSink {
|
impl Sink for FileSink {
|
||||||
fn set_uri(&mut self, uri_str: &Option<String>) -> bool {
|
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool {
|
||||||
match *uri_str {
|
match *uri_str {
|
||||||
None => {
|
None => {
|
||||||
self.location = None;
|
self.location = None;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
Some(ref uri_str) => {
|
Some(ref uri_str) => {
|
||||||
let uri_parsed = Url::parse(uri_str.as_str());
|
let uri_parsed = Url::parse(uri_str);
|
||||||
match uri_parsed {
|
match uri_parsed {
|
||||||
Ok(u) => {
|
Ok(u) => {
|
||||||
match u.to_file_path().ok() {
|
match u.to_file_path().ok() {
|
||||||
|
|
|
@ -51,14 +51,14 @@ impl FileSrc {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Source for FileSrc {
|
impl Source for FileSrc {
|
||||||
fn set_uri(&mut self, uri_str: &Option<String>) -> bool {
|
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool {
|
||||||
match *uri_str {
|
match *uri_str {
|
||||||
None => {
|
None => {
|
||||||
self.location = None;
|
self.location = None;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
Some(ref uri_str) => {
|
Some(ref uri_str) => {
|
||||||
let uri_parsed = Url::parse(uri_str.as_str());
|
let uri_parsed = Url::parse(uri_str);
|
||||||
match uri_parsed {
|
match uri_parsed {
|
||||||
Ok(u) => {
|
Ok(u) => {
|
||||||
match u.to_file_path().ok() {
|
match u.to_file_path().ok() {
|
||||||
|
|
|
@ -123,7 +123,7 @@ impl HttpSrc {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Source for HttpSrc {
|
impl Source for HttpSrc {
|
||||||
fn set_uri(&mut self, uri_str: &Option<String>) -> bool {
|
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool {
|
||||||
if self.response.is_some() {
|
if self.response.is_some() {
|
||||||
println_err!("Can't set URI after starting");
|
println_err!("Can't set URI after starting");
|
||||||
return false;
|
return false;
|
||||||
|
@ -135,7 +135,7 @@ impl Source for HttpSrc {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
Some(ref uri_str) => {
|
Some(ref uri_str) => {
|
||||||
let uri_parsed = Url::parse(uri_str.as_str());
|
let uri_parsed = Url::parse(uri_str);
|
||||||
match uri_parsed {
|
match uri_parsed {
|
||||||
Ok(u) => {
|
Ok(u) => {
|
||||||
if u.scheme() == "http" ||
|
if u.scheme() == "http" ||
|
||||||
|
|
|
@ -24,7 +24,7 @@ use std::ptr;
|
||||||
use utils::*;
|
use utils::*;
|
||||||
|
|
||||||
pub trait Sink: Sync + Send {
|
pub trait Sink: Sync + Send {
|
||||||
fn set_uri(&mut self, uri_str: &Option<String>) -> bool;
|
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool;
|
||||||
fn get_uri(&self) -> Option<String>;
|
fn get_uri(&self) -> Option<String>;
|
||||||
fn start(&mut self) -> bool;
|
fn start(&mut self) -> bool;
|
||||||
fn stop(&mut self) -> bool;
|
fn stop(&mut self) -> bool;
|
||||||
|
@ -44,7 +44,7 @@ pub extern "C" fn sink_set_uri(ptr: *mut Box<Sink>, uri_ptr: *const c_char) -> G
|
||||||
GBoolean::from_bool(source.set_uri(&None))
|
GBoolean::from_bool(source.set_uri(&None))
|
||||||
} else {
|
} else {
|
||||||
let uri = unsafe { CStr::from_ptr(uri_ptr) };
|
let uri = unsafe { CStr::from_ptr(uri_ptr) };
|
||||||
GBoolean::from_bool(source.set_uri(&Some(String::from(uri.to_str().unwrap()))))
|
GBoolean::from_bool(source.set_uri(&Some(uri.to_str().unwrap())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use std::ptr;
|
||||||
use utils::*;
|
use utils::*;
|
||||||
|
|
||||||
pub trait Source: Sync + Send {
|
pub trait Source: Sync + Send {
|
||||||
fn set_uri(&mut self, uri_str: &Option<String>) -> bool;
|
fn set_uri(&mut self, uri_str: &Option<&str>) -> bool;
|
||||||
fn get_uri(&self) -> Option<String>;
|
fn get_uri(&self) -> Option<String>;
|
||||||
fn is_seekable(&self) -> bool;
|
fn is_seekable(&self) -> bool;
|
||||||
fn get_size(&self) -> u64;
|
fn get_size(&self) -> u64;
|
||||||
|
@ -48,7 +48,7 @@ pub extern "C" fn source_set_uri(ptr: *mut Box<Source>, uri_ptr: *const c_char)
|
||||||
GBoolean::from_bool(source.set_uri(&None))
|
GBoolean::from_bool(source.set_uri(&None))
|
||||||
} else {
|
} else {
|
||||||
let uri = unsafe { CStr::from_ptr(uri_ptr) };
|
let uri = unsafe { CStr::from_ptr(uri_ptr) };
|
||||||
GBoolean::from_bool(source.set_uri(&Some(String::from(uri.to_str().unwrap()))))
|
GBoolean::from_bool(source.set_uri(&Some(uri.to_str().unwrap())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue