pub struct Fetcher<BS, DS, PS, NS> {
http_client: Client,
blob_service: BS,
directory_service: DS,
path_info_service: PS,
nar_calculation_service: NS,
}
Expand description
Knows how to fetch a given Fetch.
Fields§
§http_client: Client
§blob_service: BS
§directory_service: DS
§path_info_service: PS
§nar_calculation_service: NS
Implementations§
source§impl<BS, DS, PS, NS> Fetcher<BS, DS, PS, NS>
impl<BS, DS, PS, NS> Fetcher<BS, DS, PS, NS>
pub fn new( blob_service: BS, directory_service: DS, path_info_service: PS, nar_calculation_service: NS, ) -> Self
sourceasync fn download(
&self,
url: Url,
) -> Result<Box<dyn AsyncBufRead + Unpin + Send>, FetcherError>
async fn download( &self, url: Url, ) -> Result<Box<dyn AsyncBufRead + Unpin + Send>, FetcherError>
Constructs a HTTP request to the passed URL, and returns a AsyncReadBuf to it. In case the URI uses the file:// scheme, use tokio::fs to open it.
source§impl<BS, DS, PS, NS> Fetcher<BS, DS, PS, NS>where
BS: BlobService + Clone + 'static,
DS: DirectoryService + Clone,
PS: PathInfoService,
NS: NarCalculationService,
impl<BS, DS, PS, NS> Fetcher<BS, DS, PS, NS>where
BS: BlobService + Clone + 'static,
DS: DirectoryService + Clone,
PS: PathInfoService,
NS: NarCalculationService,
sourcepub async fn ingest(
&self,
fetch: Fetch,
) -> Result<(Node, CAHash, u64), FetcherError>
pub async fn ingest( &self, fetch: Fetch, ) -> Result<(Node, CAHash, u64), FetcherError>
Ingest the data from a specified Fetch. On success, return the root node, a content digest and length. Returns an error if there was a failure during fetching, or the contents didn’t match the previously communicated hash contained inside the FetchArgs.
sourcepub async fn ingest_and_persist<'a>(
&self,
name: &'a str,
fetch: Fetch,
) -> Result<(StorePathRef<'a>, Node), FetcherError>
pub async fn ingest_and_persist<'a>( &self, name: &'a str, fetch: Fetch, ) -> Result<(StorePathRef<'a>, Node), FetcherError>
Ingests the data from a specified Fetch, persists the returned node in the PathInfoService, and returns the calculated StorePath, as well as the root node pointing to the contents. The root node can be used to descend into the data without doing the lookup to the PathInfoService again.
Auto Trait Implementations§
impl<BS, DS, PS, NS> Freeze for Fetcher<BS, DS, PS, NS>
impl<BS, DS, PS, NS> !RefUnwindSafe for Fetcher<BS, DS, PS, NS>
impl<BS, DS, PS, NS> Send for Fetcher<BS, DS, PS, NS>
impl<BS, DS, PS, NS> Sync for Fetcher<BS, DS, PS, NS>
impl<BS, DS, PS, NS> Unpin for Fetcher<BS, DS, PS, NS>
impl<BS, DS, PS, NS> !UnwindSafe for Fetcher<BS, DS, PS, NS>
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
Mutably borrows from an owned value. Read more
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Converts
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>
Converts
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request