pub struct FetchRequest<'a> { /* private fields */ }Expand description
The inputs to one fetch.
Fetch::fetch takes its inputs as this value rather than as loose
parameters, so that per-request context an implementation comes to need — a
byte range, an expected digest, a conditional-request stamp, extra headers —
can be added as accessors without changing the trait method’s signature.
A Fetch implementation reads what it understands and ignores the rest.
Implementations§
Source§impl<'a> FetchRequest<'a>
impl<'a> FetchRequest<'a>
Sourcepub fn new(url: &'a str) -> FetchRequest<'a>
pub fn new(url: &'a str) -> FetchRequest<'a>
Returns a request for url.
Sourcepub fn sized(self, bytes: u64) -> FetchRequest<'a>
pub fn sized(self, bytes: u64) -> FetchRequest<'a>
Records the size the body is expected to be, in bytes.
The provisioner states it wherever a verified source declares it: the signed release records the length of every index alongside its digest, and the index records the length of every package. Both are known before the request is made and are as trustworthy as the signature they hang from.
Sourcepub fn url(&self) -> &'a str
pub fn url(&self) -> &'a str
The URL to fetch.
The scheme is case-insensitive (RFC 3986 §3.1); the rest of the URL is
not. An implementation that routes on the scheme — handing https://
URLs to a TLS transport and delegating the rest, say — reaches it
through scheme rather than by splitting this string,
so that the two layers cannot disagree about which URLs name TLS.
Sourcepub fn scheme(&self) -> Option<&'a str>
pub fn scheme(&self) -> Option<&'a str>
The scheme the URL names, or None for a reference that names none.
This is the accessor a transport routes on. The scheme is the text
before ://, spelled ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) by
RFC 3986 §3.1, so a path reference that happens to contain :// does
not read as one. None is a real input rather than a broken one: a
caller may name a mirror by a bare path, and a transport that serves
only absolute URLs answers it with FetchError::url.
It is returned exactly as written. Schemes are case-insensitive, so a
comparison against it must be too — this crate’s own client matches
HTTP:// and http:// alike, and a transport that matched literally
would refuse URLs the layer above it had already accepted.
§Example
Routing by scheme, compared the way the rule requires:
use ferroday_cage::provision::FetchRequest;
let request = FetchRequest::new("HTTPS://deb.debian.org/debian/Release");
let scheme = request.scheme().unwrap_or_default();
// `eq_ignore_ascii_case`, not `==`: the archive may be configured in
// any case, and the two spellings name one transport.
assert!(scheme.eq_ignore_ascii_case("https"));
assert_eq!(scheme, "HTTPS", "the scheme is returned as written");Sourcepub fn size(&self) -> Option<u64>
pub fn size(&self) -> Option<u64>
The size the body is expected to be, or None where nothing declares
one — a release file, which is the trust root and so has no signed
length of its own.
An implementation that honours it refuses a body larger than the stated size, and may refuse a declared framing larger than it before reading anything: a mirror that answers a request for a few megabytes with gigabytes is not serving the resource that was asked for, and the digest check that would catch the substitution runs only after the bytes have been spent. It is a ceiling, not a promise — an implementation is free to ignore it, and the provisioner bounds its own sink regardless.
Trait Implementations§
Source§impl<'a> Clone for FetchRequest<'a>
impl<'a> Clone for FetchRequest<'a>
Source§fn clone(&self) -> FetchRequest<'a>
fn clone(&self) -> FetchRequest<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for FetchRequest<'a>
Auto Trait Implementations§
impl<'a> Freeze for FetchRequest<'a>
impl<'a> RefUnwindSafe for FetchRequest<'a>
impl<'a> Send for FetchRequest<'a>
impl<'a> Sync for FetchRequest<'a>
impl<'a> Unpin for FetchRequest<'a>
impl<'a> UnsafeUnpin for FetchRequest<'a>
impl<'a> UnwindSafe for FetchRequest<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.