Skip to main content

FetchCmd

Struct FetchCmd 

Source
#[non_exhaustive]
pub struct FetchCmd { pub cancel: Option<CancellationToken>, pub headers: Option<Headers>, pub on_complete: Option<OnCompleteFn>, pub on_response: Option<OnResponseFn>, pub range: Option<RangeSpec>, pub validator: Option<fn(&Headers) -> NetResult<()>>, pub writer: Option<WriterFn>, pub method: RequestMethod, pub url: Url, }
Expand description

A single download command.

Built by protocol code via FetchCmd::get / FetchCmd::head constructors and executed via PeerHandle::execute. The downloader establishes the HTTP connection and returns a FetchResponse with headers and a body stream.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§cancel: Option<CancellationToken>

Epoch cancel token from the Peer. When set, the Downloader combines it with the track-level cancel via [CancelGroup].

§headers: Option<Headers>

Additional HTTP headers for this request.

§on_complete: Option<OnCompleteFn>

Streaming path completion handler. None for channel path (execute/batch).

§on_response: Option<OnResponseFn>

Streaming path response callback — fires once when the response is ready, before the body streams. None for the channel path (execute/batch).

§range: Option<RangeSpec>

Optional byte range (HTTP Range request).

§validator: Option<fn(&Headers) -> NetResult<()>>

Optional per-request response validator. Called with the response headers after a successful HTTP response. Return Err to reject the response before the body is consumed.

§writer: Option<WriterFn>

Streaming path body writer. None for channel path (execute/batch).

§method: RequestMethod

HTTP method.

§url: Url

URL to fetch.

Implementations§

Source§

impl FetchCmd

Source

pub fn builder() -> FetchCmdBuilder

Create an instance of FetchCmd using the builder syntax

Source§

impl FetchCmd

Source

pub fn get(url: Url) -> FetchCmdBuilder<SetUrl<SetMethod>>

Builder for an HTTP GET command targeting the given URL.

Source

pub fn head(url: Url) -> FetchCmdBuilder<SetUrl<SetMethod>>

Builder for an HTTP HEAD command targeting the given URL.

Trait Implementations§

Source§

impl Debug for FetchCmd

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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
Source§

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