silk.http.fetch.
Send one HTTP request, follow redirects, decode the content, and deliver the body to a destination that you choose.
When to use#
Use this module when you need more control than silk.http.client: a sink for a large body, a
body that you stream, content decoding, a proxy, or a connection pool. Make a Fetch around a
FetchClient, such as the Context of silk.http.fetch_native. Then call one function for
each request.
Details#
There are three destinations:
toSink*gives the body to aSinkin chunks, in order.collect*reads the whole body into memory, up tomaxBodyBytes, and returns it only if it is complete.discard*reads and checks the body, and keeps nothing.
The suffix tells what the request body is:
Empty: no body.Bytes: a byte slice. It is sent again after a redirect that keeps the body.OneShot: aBodyProducerthat can run only one time. A redirect that must send the body again fails withReplayUnavailable.Replay: a factory that makes a new producer for each attempt.
FetchOptions sets redirects, content decoding, the pool, the proxy, one deadline for the
whole operation, and all limits. silk.http.redirect applies the redirect rules, and
silk.http.content decodes the content.
Errors#
FetchErrortells the phase and the reason, with the status and the URI when they are known, and how many body bytes the destination got.RedirectError,ExchangeError,ValueError, andBodyErrorfrom the lower modules.DestinationFailurewhen yourSinkfails.OutOfMemoryErrorif theAllocatorfails.
Gotchas#
The deadline is not renewed between redirects or phases. The default FetchOptions do not
follow redirects and do not decode content. Set redirect and content to change that.
Import as Fetch with import silk.http.fetch { Fetch }.
Public declarations: 30.
PoolMode#
pub enum PoolModeWhether a connection can come from a pool.
UseContextPool#
UseContextPoolUse the pool of the client when it has one. Otherwise open a new connection.
Fresh#
FreshAlways open a new connection, and never put it in a pool.
ProxyMode#
pub enum ProxyModeWhether the request uses the proxy policy of the client.
InheritContext#
InheritContextUse the proxy policy of the client. The route is selected again for each redirect.
Direct#
DirectConnect directly to the origin, without a proxy. Environment variables are not read.
FetchPhase#
pub enum FetchPhaseThe phase of a fetch in which an error occurred.
Uri#
UriChecking or copying the URI.
Route#
RouteSelecting the route for an origin.
Connect#
ConnectGetting a connection: the pool, name lookup, the connect, or TLS.
Request#
RequestPreparing or sending the request.
Redirect#
RedirectApplying the redirect rules.
Head#
HeadReading or copying the final response head.
Decode#
DecodeDecoding the content, the framing, or the trailers.
Destination#
DestinationGiving the body to the sink, the collection, or the discard.
Finish#
FinishCompleting the response and deciding if the connection can be used again.
Implementation Debug for FetchPhase#
impl Debug for FetchPhaseOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as Uri.
FetchLimit#
pub enum FetchLimitThe fetch limit that was exceeded. See FetchReason.LimitExceeded.
EncodedBodyBytes#
EncodedBodyBytesmaxEncodedBodyBytes: the body bytes before decoding.
DeliveredBodyBytes#
DeliveredBodyBytesmaxDeliveredBodyBytes: the body bytes given to the destination.
OwnedMetadataBytes#
OwnedMetadataBytesmaxOwnedMetadataBytes: the copies of the URI, the head, and the trailers.
BufferedBytes#
BufferedBytesmaxBufferedBytes: the read buffer.
CollectionBytes#
CollectionBytesThe maxBodyBytes of a collect* function.
DiscardBytes#
DiscardBytesThe maxDiscardBytes of a discard* function.
Implementation Debug for FetchLimit#
impl Debug for FetchLimitOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as EncodedBodyBytes.
FetchContentReason#
pub union FetchContentReasonThe reason that content decoding failed. It is a copy of the silk.http.content error that does
not borrow the response.
InvalidLimit#
InvalidLimitA content limit is not valid, or a byte count exceeded it.
Field limit#
pub limit: ContentLimitKindThe limit.
Field allowed#
pub allowed: u64The value of the limit.
Field attempted#
pub attempted: u64The value that was found.
CodingSyntax#
CodingSyntaxAn item in Content-Encoding is empty or not valid.
Field position#
pub position: CodingPositionWhere the item is.
UnsupportedCoding#
UnsupportedCodingA content coding has no decoder, for example br.
Field position#
pub position: CodingPositionWhere the coding is.
Field token#
pub token: BytesA copy of the coding name.
PartialResponse#
PartialResponseA 206 partial response has a coding other than identity, which cannot be decoded.
Field position#
pub position: CodingPositionThe first coding that is not identity.
Tunnel#
TunnelThe response body is a tunnel, not content.
Body#
BodyThe body framing failed.
Field error#
pub error: BodyErrorThe error from silk.http.body.
Buffer#
BufferReading from the transport failed.
Field error#
pub error: BufferErrorThe error, with its transport cause.
Inflate#
InflateGzip or zlib decoding failed.
Field stage#
pub stage: usizeThe decoding stage, from 0, counted from the last coding.
Field wireIndex#
pub wireIndex: usizeThe position of the coding in Content-Encoding, from 0.
Field error#
pub error: DecodeErrorThe error from silk.compress.inflate.
Zstandard#
ZstandardZstandard decoding failed.
Field stage#
pub stage: usizeThe decoding stage, from 0, counted from the last coding.
Field wireIndex#
pub wireIndex: usizeThe position of the coding in Content-Encoding, from 0.
Field error#
pub error: ZstdErrorThe error from silk.compress.zstd.
TrailingEncodedData#
TrailingEncodedDataThere were more bytes after the end of a compressed stream.
Field stage#
pub stage: usizeThe decoding stage, from 0, counted from the last coding.
Field wireIndex#
pub wireIndex: usizeThe position of the coding in Content-Encoding, from 0.
ArithmeticOverflow#
ArithmeticOverflowA byte count overflowed.
InvalidState#
InvalidStateThe content reader had already failed or stopped.
Implementation Debug for FetchContentReason#
impl Debug for FetchContentReasonOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant and its fields, such as InvalidLimit { ... }.
FetchContentError#
pub struct FetchContentErrorA content decoding error, with byte counts. It owns its data.
Field reason#
pub reason: FetchContentReasonThe reason.
Field written#
pub written: usizeThe bytes written to the current output chunk.
Field totalEncoded#
pub totalEncoded: u64The total encoded bytes read.
Field totalIntermediate#
pub totalIntermediate: u64The total bytes from decoding stages before the last one.
Field totalDecoded#
pub totalDecoded: u64The total decoded bytes.
Implementation Debug for FetchContentError#
impl Debug for FetchContentErrorOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the fields, as FetchContentError { reason: ..., written: ..., ... }.
FetchReason#
pub union FetchReasonThe reason of a FetchError.
InvalidOptions#
InvalidOptionsThe FetchOptions are not valid. See FetchOptions.validate.
InvalidHttpOptions#
InvalidHttpOptionsThe client rejected the HTTP limits in the options.
Field error#
pub error: ExchangeErrorThe error from the client.
HttpValue#
HttpValueCopying an HTTP value failed.
Field error#
pub error: ValueErrorThe error from silk.http.message.
HttpBody#
HttpBodyThe body or the trailers of the final response are not valid.
Field error#
pub error: BodyErrorThe error from silk.http.body.
HttpClient#
HttpClientThe exchange failed while the body of the final response was read.
Field error#
pub error: ExchangeErrorThe error from silk.http.exchange.
SizeOverflow#
SizeOverflowA byte count overflowed.
DestinationRejected#
DestinationRejectedYour sink rejected a chunk.
Content#
ContentContent decoding failed.
Field error#
pub error: FetchContentErrorThe content error.
LimitExceeded#
LimitExceededA limit in FetchOptions or in the call was exceeded.
Field limit#
pub limit: FetchLimitThe limit.
Field allowed#
pub allowed: u64The value of the limit.
Field attempted#
pub attempted: u64The value that was found.
UnsupportedSwitchingResponse#
UnsupportedSwitchingResponseThe final response is 101 Switching Protocols, or a 2xx for CONNECT. Fetch cannot use the
connection after such a response.
Field status#
pub status: StatusThe status of the response.
Implementation Debug for FetchReason#
impl Debug for FetchReasonOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant and its fields, such as InvalidOptions.
FetchError#
pub struct FetchErrorThe error from a fetch, with context. It owns its data.
Details#
It tells the phase and the reason, with the status and the URI when they are known, and how many body bytes the destination got.
Field phase#
pub phase: FetchPhaseThe phase in which the error occurred.
Field reason#
pub reason: FetchReasonThe reason.
Field status#
pub status: Option<Status>The status of the final response, when it is known.
Field uri#
pub uri: Option<OwnedUri>A copy of the current URI, when it is known.
Field deliveredBodyBytes#
pub deliveredBodyBytes: u64The body bytes that the destination accepted before the error.
Field offeredBodyBytes#
pub offeredBodyBytes: usizeThe length of the chunk that the destination rejected, or 0.
Implementation Debug for FetchError#
impl Debug for FetchErrorOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the fields, as FetchError { phase: ..., reason: ..., ... }.
DestinationFailure#
pub struct DestinationFailure<E>The error from your Sink, with the context of the fetch.
Field error#
pub error: EThe error from your sink.
Field context#
pub context: FetchErrorThe context: the phase, the status, the URI, and the bytes delivered before the error.
Implementation Debug for DestinationFailure<E>#
impl<E: Debug> Debug for DestinationFailure<E>Operation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the fields, as DestinationFailure { error: ..., context: ... }.
RepresentationMetadata#
pub struct RepresentationMetadataHow the content of the response was decoded.
Field applied#
pub applied: AppliedPlanThe decoding plan that was used: raw, or which codings were decoded.
Field completed#
pub completed: booltrue when the framing and all decoding completed.
Field deliveredBytes#
pub deliveredBytes: Option<u64>The number of body bytes delivered, after completion.
ResponseMetadata#
pub struct ResponseMetadataThe head of the final response, and how its content is decoded. Your sink gets it with each chunk.
Field finalUri#
pub finalUri: OwnedUriThe URI of the final response, after redirects.
Field head#
pub head: OwnedResponseHeadThe status, the reason, and the headers of the final response, as received.
Field representation#
pub representation: RepresentationMetadataHow the content is decoded. The headers are not changed by decoding.
Field ownedBytes#
pub ownedBytes: usizeThe memory of the URI and head copies, in bytes.
FetchResult#
pub struct FetchResultThe result of a complete response, without the body.
Field metadata#
pub metadata: ResponseMetadataThe final URI and head.
Field trailers#
pub trailers: Option<OwnedTrailers>The trailers of a chunked response, if any.
Field redirectCount#
pub redirectCount: usizeThe number of redirects that were followed.
Field encodedBodyBytes#
pub encodedBodyBytes: u64The body bytes before decoding.
Field deliveredBodyBytes#
pub deliveredBodyBytes: u64The body bytes that the destination accepted.
Field ownedMetadataBytes#
pub ownedMetadataBytes: usizeThe memory of the URI, head, and trailer copies, in bytes.
CollectedResponse#
pub struct CollectedResponseThe result of a collect* function: the response and its whole body.
Field result#
pub result: FetchResultThe response without the body.
Field body#
pub body: BytesThe whole body, decoded as selected in the options.
FetchRequest#
pub struct FetchRequest<'uri, 'method, 'headers, 'policy>The method, URI, headers, and header policy of a request. The body comes from the function that you call.
Implementation FetchRequest<'uri, 'method, 'headers, 'policy>#
impl<'uri, 'method, 'headers, 'policy> FetchRequest<'uri, 'method, 'headers, 'policy>Associated function make#
pub fn make(
uri: Uri<'uri>,
method: Method<'method>,
headers: Headers<'headers>,
headerPolicy: HeaderPolicy<'policy>,
version: Version,
continuePolicy: ContinuePolicy,
limits: HeaderLimits,
maxHeadBytes: usize,
maxCredentialBytes: usize,
) -> SelfReturns a request. continuePolicy selects Expect: 100-continue. The limits apply to the
head that is sent. See prepare in silk.http.request.
Associated function get#
pub fn get(uri: Uri<'uri>) -> SelfReturns a GET request for uri, with no headers, the default header policy, and the default
limits.
FetchOptions#
pub struct FetchOptionsThe settings of a fetch: redirects, content decoding, the pool, the proxy, one deadline for the
whole operation, and all limits. Start from FetchOptions.defaults.
Gotchas#
The deadline is not renewed between redirects or phases. The defaults do not follow redirects
and do not decode content. Set redirect and content to change that.
Field redirect#
pub redirect: RedirectPolicyWhether and how to follow redirects. See silk.http.redirect.
Field content#
pub content: ContentModeWhether to give the body raw or decoded. See silk.http.content.
Field pool#
pub pool: PoolModeWhether a connection can come from a pool.
Field proxy#
pub proxy: ProxyModeWhether to use the proxy policy of the client.
Field deadline#
pub deadline: Option<Instant>One deadline on the MonotonicClock for the whole operation, including all redirects.
Field http#
pub http: ClientLimitsThe limits for the HTTP exchange: heads, framing, trailers, and buffers.
Field contentLimits#
pub contentLimits: ContentLimitsThe limits for content decoding.
Field maxEncodedBodyBytes#
pub maxEncodedBodyBytes: u64The maximum body bytes before decoding.
Field maxDeliveredBodyBytes#
pub maxDeliveredBodyBytes: u64The maximum body bytes that any destination gets.
Field maxOwnedMetadataBytes#
pub maxOwnedMetadataBytes: usizeThe maximum memory for the copies of the URI, the head, and the trailers.
Field maxBufferedBytes#
pub maxBufferedBytes: usizeThe size of the read buffer for the body. It must not be 0.
Implementation FetchOptions#
impl FetchOptionsAssociated function defaults#
pub fn defaults() -> FetchOptionsReturns options that do not follow redirects, do not decode content, use the pool and proxy policy of the client, have no deadline, and allow bodies of 16 MiB.
Method validate#
pub fn validate(self: &Self) -> Result<(), FetchError>Checks that the options are consistent. It does not allocate or connect. Each fetch function calls it first.
Fetch#
pub struct Fetch<C>A fetch client around a FetchClient. Make it with Fetch.make, and pass it to the fetch
functions.
When to use#
Use it when you need more control than silk.http.client: a sink for a large body, a body that
you stream, content decoding, a proxy, or a connection pool. Use the Context of
silk.http.fetch_native as the client.
Details#
Each fetch function sends one request, follows redirects, decodes the content, and delivers the
body. The prefix of the function name tells the destination: toSink* gives the body to a
Sink in chunks, in order; collect* reads the whole body into memory, up to
maxBodyBytes, and returns it only if it is complete; discard* reads and checks the body and
keeps nothing. The suffix tells the request body: Empty; Bytes, sent again after a redirect
that keeps the body; OneShot, a producer that runs one time, so a redirect that must send the
body again fails with ReplayUnavailable; or Replay, a factory that makes a new producer for
each attempt.
Gotchas#
The deadline is not renewed between redirects or phases. The default FetchOptions do not
follow redirects and do not decode content.
Implementation Fetch<C>#
impl<C> Fetch<C>Associated function make#
pub fn make(client: C) -> Fetch<C>Returns a fetch client that uses client to get connections.
Sink#
pub interface Sink<E, ?R>A destination for the body chunks of a toSink* function. The chunks arrive in order. A
failure of the sink becomes a DestinationFailure.
Operation write#
effect<'call> fn write<'call>(
sink: &mut Self,
metadata: &'call ResponseMetadata,
chunk: &'call [u8],
deadline: &'call Option<Instant>,
) -> () ! E ? RAccepts one chunk of the body.
Details#
metadata is the final response head. deadline is the deadline of the whole fetch, or
None. The fetch reads no more body until this call returns. The chunk and the metadata are
only borrowed for this call.
FetchClient#
pub interface FetchClient<
'policy,
RoutedP,
DirectP,
A,
HandlerError,
AcquisitionError,
?HandlerRequirements,
?AcquisitionRequirements,
>Gets a connection and runs one attempt of a request. A fetch calls it again for each redirect.
Details#
An implementation checks the options before it connects, and selects the route for the current
URI. With Fresh, it does not use a pool. With Direct, it does not use a proxy policy.
deadline is the deadline of the whole fetch.
Operation withAttempt#
effect fn withAttempt(
client: &mut Self,
request: AttemptRequest<'policy>,
httpLimits: ClientLimits,
poolMode: PoolMode,
proxyMode: ProxyMode,
deadline: Option<Instant>,
) -> A ! HandlerError | AcquisitionError ? HandlerRequirements | AcquisitionRequirements | &mut HybridAttempt<'policy, RoutedP, DirectP, A, HandlerError ? HandlerRequirements> where
HandlerRequirements in Without<HandlerRequirements, ByteDuplex>,
HandlerRequirements in Without<HandlerRequirements, HttpTransport>Connects and runs one attempt of request with these limits and modes.
toSinkEmpty#
pub effect<'env> fn toSinkEmpty<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
SinkError: Intrinsic.Detached,
AcquisitionError,
?SinkRequirements,
?AcquisitionRequirements,
S: Sink<SinkError ? SinkRequirements> + 'env,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError,
AcquisitionError,
SinkRequirements | &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
options: FetchOptions,
sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError | AcquisitionError
? SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
SinkRequirements in Without<SinkRequirements, ByteDuplex>,
SinkRequirements in Without<SinkRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request with no body, and gives the body of the final response to sink in chunks.
collectEmpty#
pub effect fn collectEmpty<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
AcquisitionError,
?AcquisitionRequirements,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, CollectedResponse>,
RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
AcquisitionError,
&mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
options: FetchOptions,
maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request with no body, and returns the body of the final response in memory. More than
maxBodyBytes fails, and no partial body is returned.
discardEmpty#
pub effect fn discardEmpty<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
AcquisitionError,
?AcquisitionRequirements,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
AcquisitionError,
&mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
options: FetchOptions,
maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request with no body, and reads and checks the body of the final response without
keeping it. More than maxDiscardBytes fails.
toSinkBytes#
pub effect<'env> fn toSinkBytes<
'fetch,
'uri,
'method,
'headers,
'policy,
'bytes,
RoutedP,
DirectP,
SinkError: Intrinsic.Detached,
AcquisitionError,
?SinkRequirements,
?AcquisitionRequirements,
S: Sink<SinkError ? SinkRequirements> + 'env,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError,
AcquisitionError,
SinkRequirements | &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
bytes: &'bytes [u8],
options: FetchOptions,
sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError | AcquisitionError
? SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
SinkRequirements in Without<SinkRequirements, ByteDuplex>,
SinkRequirements in Without<SinkRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request with the body bytes, and gives the body of the final response to sink in
chunks.
collectBytes#
pub effect fn collectBytes<
'fetch,
'uri,
'method,
'headers,
'policy,
'bytes,
RoutedP,
DirectP,
AcquisitionError,
?AcquisitionRequirements,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, CollectedResponse>,
RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
AcquisitionError,
&mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
bytes: &'bytes [u8],
options: FetchOptions,
maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request with the body bytes, and returns the body of the final response in memory.
More than maxBodyBytes fails, and no partial body is returned.
discardBytes#
pub effect fn discardBytes<
'fetch,
'uri,
'method,
'headers,
'policy,
'bytes,
RoutedP,
DirectP,
AcquisitionError,
?AcquisitionRequirements,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
AcquisitionError,
&mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
bytes: &'bytes [u8],
options: FetchOptions,
maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request with the body bytes, and reads and checks the body of the final response
without keeping it. More than maxDiscardBytes fails.
toSinkOneShot#
pub effect<'env> fn toSinkOneShot<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
ProducerError,
SinkError: Intrinsic.Detached,
AcquisitionError,
?ProducerRequirements,
?SinkRequirements,
?AcquisitionRequirements,
Producer: BodyProducer<ProducerError ? ProducerRequirements> + 'env,
S: Sink<SinkError ? SinkRequirements> + 'env,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | ProducerError | DestinationFailure<
SinkError,
> | ExchangeError | OutOfMemoryError,
AcquisitionError,
ProducerRequirements | SinkRequirements | &mut Redirect.SelectedBody<
ProducerError,
ProducerRequirements,
> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
producer: Producer,
options: FetchOptions,
sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ProducerError | DestinationFailure<
SinkError,
> | ExchangeError | OutOfMemoryError | AcquisitionError
? ProducerRequirements | SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
SinkRequirements in Without<SinkRequirements, ByteDuplex>,
SinkRequirements in Without<SinkRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request whose body comes from producer one time, and gives the body of the final
response to sink in chunks.
collectOneShot#
pub effect<'env> fn collectOneShot<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
ProducerError,
AcquisitionError,
?ProducerRequirements,
?AcquisitionRequirements,
Producer: BodyProducer<ProducerError ? ProducerRequirements> + 'env,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, CollectedResponse>,
RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
AcquisitionError,
ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
producer: Producer,
options: FetchOptions,
maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request whose body comes from producer one time, and returns the body of the final
response in memory. More than maxBodyBytes fails, and no partial body is returned.
discardOneShot#
pub effect<'env> fn discardOneShot<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
ProducerError,
AcquisitionError,
?ProducerRequirements,
?AcquisitionRequirements,
Producer: BodyProducer<ProducerError ? ProducerRequirements> + 'env,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
AcquisitionError,
ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
producer: Producer,
options: FetchOptions,
maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request whose body comes from producer one time, and reads and checks the body of the
final response without keeping it. More than maxDiscardBytes fails.
toSinkReplay#
pub effect<'env> fn toSinkReplay<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
FactoryError,
ProducerError,
SinkError: Intrinsic.Detached,
AcquisitionError,
?FactoryRequirements,
?ProducerRequirements,
?SinkRequirements,
?AcquisitionRequirements,
Factory: ReplayFactory<Producer, FactoryError, FactoryRequirements> + 'env,
Producer: BodyProducer<ProducerError ? ProducerRequirements>,
S: Sink<SinkError ? SinkRequirements> + 'env,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | ProducerError | DestinationFailure<
SinkError,
> | ExchangeError | OutOfMemoryError,
AcquisitionError,
ProducerRequirements | SinkRequirements | &mut Redirect.SelectedBody<
ProducerError,
ProducerRequirements,
> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
factory: Factory,
options: FetchOptions,
sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | FactoryError | ProducerError | DestinationFailure<
SinkError,
> | ExchangeError | OutOfMemoryError | AcquisitionError
? FactoryRequirements | ProducerRequirements | SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
FactoryRequirements in Without<FactoryRequirements, ByteDuplex>,
FactoryRequirements in Without<FactoryRequirements, HttpTransport>,
ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
SinkRequirements in Without<SinkRequirements, ByteDuplex>,
SinkRequirements in Without<SinkRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request whose body comes from a new producer from factory for each attempt, and gives
the body of the final response to sink in chunks.
collectReplay#
pub effect<'env> fn collectReplay<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
FactoryError,
ProducerError,
AcquisitionError,
?FactoryRequirements,
?ProducerRequirements,
?AcquisitionRequirements,
Factory: ReplayFactory<Producer, FactoryError, FactoryRequirements> + 'env,
Producer: BodyProducer<ProducerError ? ProducerRequirements>,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, CollectedResponse>,
RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
AcquisitionError,
ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
factory: Factory,
options: FetchOptions,
maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | FactoryError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? FactoryRequirements | ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
FactoryRequirements in Without<FactoryRequirements, ByteDuplex>,
FactoryRequirements in Without<FactoryRequirements, HttpTransport>,
ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request whose body comes from a new producer from factory for each attempt, and
returns the body of the final response in memory. More than maxBodyBytes fails, and no partial
body is returned.
discardReplay#
pub effect<'env> fn discardReplay<
'fetch,
'uri,
'method,
'headers,
'policy,
RoutedP,
DirectP,
FactoryError,
ProducerError,
AcquisitionError,
?FactoryRequirements,
?ProducerRequirements,
?AcquisitionRequirements,
Factory: ReplayFactory<Producer, FactoryError, FactoryRequirements> + 'env,
Producer: BodyProducer<ProducerError ? ProducerRequirements>,
C: FetchClient<
'policy,
RoutedP,
DirectP,
Redirect.AttemptStep<'policy, FetchResult>,
RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
AcquisitionError,
ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
AcquisitionRequirements,
>,
'env,
>(
fetch: &'fetch mut Fetch<C>,
request: FetchRequest<'uri, 'method, 'headers, 'policy>,
factory: Factory,
options: FetchOptions,
maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | FactoryError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? FactoryRequirements | ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
&mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &HttpTransport from &mut HttpTransport,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
&mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
&mut DirectP provides &HttpTransport from &mut HttpTransport,
FactoryRequirements in Without<FactoryRequirements, ByteDuplex>,
FactoryRequirements in Without<FactoryRequirements, HttpTransport>,
ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>Sends a request whose body comes from a new producer from factory for each attempt, and reads
and checks the body of the final response without keeping it. More than maxDiscardBytes fails.
Category: HTTP.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.