pub trait Getter {
// Required method
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dest: &'life1 str,
source: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided method
fn set_client<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Getter trait Implement this trait to add a new getter
Extending Gette
Gette is designed to be extensible. You can add your own getters by implementing this trait. the first step is to create a struct that implements this trait:
ⓘ
use gette::getter;
use async_trait::async_trait;
pub struct mygetter;
#[async_trait]
impl getter for mygetter {
async fn get(&self, _dest: &str, _source: &str) -> result<(), gette::error> {
ok(())
}
}
the next step is to add it to the builder:
use gette::RequestBuilder;
let b = RequestBuilder::builder().src("mygetter://test.txt".to_string())
.dest("test2.txt".to_string())
.add_getter("mygetter", Box::new(Mygetter))
.get()
.await
.unwrap();