pub struct Fetcher<Data> { /* private fields */ }
Expand description
An asynchronous file fetcher for clients fetching files.
The futures generated by the fetcher are compatible with single and multi-threaded runtimes, allowing you to choose between the runtime that works best for your application. A single-threaded runtime is generally recommended for fetching files, as your network connection is unlikely to be faster than a single CPU core.
Implementations§
Source§impl<Data> Fetcher<Data>
impl<Data> Fetcher<Data>
Sourcepub fn connections_per_file(self, value: u16) -> Fetcher<Data>
pub fn connections_per_file(self, value: u16) -> Fetcher<Data>
The number of concurrent connections to sustain per file being fetched.
§Note
Defaults to 1 connection
Sourcepub fn delay_between_requests(self, value: u64) -> Fetcher<Data>
pub fn delay_between_requests(self, value: u64) -> Fetcher<Data>
Sourcepub fn max_part_size(self, value: u32) -> Fetcher<Data>
pub fn max_part_size(self, value: u32) -> Fetcher<Data>
Sourcepub fn progress_interval(self, value: u64) -> Fetcher<Data>
pub fn progress_interval(self, value: u64) -> Fetcher<Data>
Sourcepub fn timeout(self, value: Duration) -> Fetcher<Data>
pub fn timeout(self, value: Duration) -> Fetcher<Data>
The time to wait between chunks before giving up.
Sourcepub fn events(
self,
value: impl Into<Arc<UnboundedSender<(Arc<Path>, Arc<Data>, FetchEvent)>>>,
) -> Fetcher<Data>
pub fn events( self, value: impl Into<Arc<UnboundedSender<(Arc<Path>, Arc<Data>, FetchEvent)>>>, ) -> Fetcher<Data>
Holds a sender for submitting events to.
Sourcepub fn shutdown(self, value: ShutdownManager<()>) -> Fetcher<Data>
pub fn shutdown(self, value: ShutdownManager<()>) -> Fetcher<Data>
Utilized to know when to shut down the fetching process.
Source§impl<Data> Fetcher<Data>
impl<Data> Fetcher<Data>
Sourcepub fn stream_from(
self: Arc<Fetcher<Data>>,
inputs: impl Stream<Item = (Source, Arc<Data>)> + Send + 'static,
concurrent: usize,
) -> Pin<Box<dyn Stream<Item = (Arc<Path>, Arc<Data>, Result<(), Error>)> + Send>>
pub fn stream_from( self: Arc<Fetcher<Data>>, inputs: impl Stream<Item = (Source, Arc<Data>)> + Send + 'static, concurrent: usize, ) -> Pin<Box<dyn Stream<Item = (Arc<Path>, Arc<Data>, Result<(), Error>)> + Send>>
Given an input stream of source fetches, returns an output stream of fetch results.
Spawns up to concurrent
+ 1
number of concurrent async tasks on the runtime.
One task for managing the fetch tasks, and one task per fetch request.
Sourcepub async fn request(
self: Arc<Fetcher<Data>>,
uris: Arc<[Box<str>]>,
to: Arc<Path>,
extra: Arc<Data>,
) -> Result<(), Error>
pub async fn request( self: Arc<Fetcher<Data>>, uris: Arc<[Box<str>]>, to: Arc<Path>, extra: Arc<Data>, ) -> Result<(), Error>
Request a file from one or more URIs.
At least one URI must be provided as a source for the file. Each additional URI serves as a mirror for failover and load-balancing purposes.
Trait Implementations§
Source§impl FetcherExt for Fetcher<Request>
impl FetcherExt for Fetcher<Request>
fn into_package_fetcher(self) -> PackageFetcher
Auto Trait Implementations§
impl<Data> Freeze for Fetcher<Data>
impl<Data> !RefUnwindSafe for Fetcher<Data>
impl<Data> Send for Fetcher<Data>
impl<Data> Sync for Fetcher<Data>
impl<Data> Unpin for Fetcher<Data>
impl<Data> !UnwindSafe for Fetcher<Data>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more