pub struct Downloader<T: Links + Assets + Href + Serialize + Clone> { /* private fields */ }
Expand description

A customizable download structure.

Implementations§

source§

impl<T: Links + Assets + Href + Serialize + Clone> Downloader<T>

source

pub fn new(stac: T) -> Result<Downloader<T>>

Creates a new downloader.

Examples
let item: stac::Item = stac::read("data/simple-item.json").unwrap();
let downloader = stac_async::Downloader::new(item);
source

pub fn create_directory(self, create_directory: bool) -> Downloader<T>

Should the downloader create the output directory?

Defaults to true.

Examples
let item: stac::Item = stac::read("data/simple-item.json").unwrap();
let downloader = stac_async::Downloader::new(item)
    .unwrap()
    .create_directory(false);
source

pub fn with_sender(self, sender: Sender<Message>) -> Downloader<T>

Set the sender for messages from this downloader.

Examples
use tokio::sync::mpsc;
use stac_async::Downloader;
use stac::Item;

let (tx, mut rx)  = mpsc::channel(100);
let item: Item = stac::read("data/simple-item.json").unwrap();
let downloader = Downloader::new(item)
    .unwrap()
    .with_sender(tx);

tokio::spawn(async move {
    downloader.download(".").await.unwrap()
});

while let Some(message) = rx.recv().await {
    dbg!(message);
}
source

pub async fn download(self, directory: impl AsRef<Path>) -> Result<T>

Downloads assets to the specified directory.

Consumes this downloader, and returns the modified object.

Examples
let item: stac::Item = stac::read("data/simple-item.json").unwrap();
let downloader = stac_async::Downloader::new(item).unwrap();
let item = downloader.download("outdir").await.unwrap();

Trait Implementations§

source§

impl<T: Debug + Links + Assets + Href + Serialize + Clone> Debug for Downloader<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Downloader<T>

§

impl<T> Send for Downloader<T>where T: Send,

§

impl<T> Sync for Downloader<T>where T: Sync,

§

impl<T> Unpin for Downloader<T>where T: Unpin,

§

impl<T> !UnwindSafe for Downloader<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more