Add trait functions for getting back the controller

This commit is contained in:
Sebastian Dröge 2016-08-25 00:08:06 +03:00
parent 82c29d369d
commit df50617c87
5 changed files with 16 additions and 0 deletions

View file

@ -62,6 +62,10 @@ impl FileSink {
} }
impl Sink for FileSink { impl Sink for FileSink {
fn get_controller(&self) -> &SinkController {
&self.controller
}
fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)> { fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)> {
let location = &mut self.settings.lock().unwrap().location; let location = &mut self.settings.lock().unwrap().location;

View file

@ -63,6 +63,10 @@ impl FileSrc {
} }
impl Source for FileSrc { impl Source for FileSrc {
fn get_controller(&self) -> &SourceController {
&self.controller
}
fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)> { fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)> {
let location = &mut self.settings.lock().unwrap().location; let location = &mut self.settings.lock().unwrap().location;

View file

@ -141,6 +141,10 @@ impl HttpSrc {
} }
impl Source for HttpSrc { impl Source for HttpSrc {
fn get_controller(&self) -> &SourceController {
&self.controller
}
fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)> { fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)> {
let url = &mut self.settings.lock().unwrap().url; let url = &mut self.settings.lock().unwrap().url;

View file

@ -38,6 +38,8 @@ impl SinkController {
} }
pub trait Sink: Sync + Send { pub trait Sink: Sync + Send {
fn get_controller(&self) -> &SinkController;
// Called from any thread at any time // Called from any thread at any time
fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)>; fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)>;
fn get_uri(&self) -> Option<Url>; fn get_uri(&self) -> Option<Url>;

View file

@ -37,6 +37,8 @@ impl SourceController {
} }
pub trait Source: Sync + Send { pub trait Source: Sync + Send {
fn get_controller(&self) -> &SourceController;
// Called from any thread at any time // Called from any thread at any time
fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)>; fn set_uri(&self, uri: Option<Url>) -> Result<(), (UriError, String)>;
fn get_uri(&self) -> Option<Url>; fn get_uri(&self) -> Option<Url>;