pub struct HttpAssetResolver {
pub max_body_bytes: usize,
/* private fields */
}Expand description
HTTP/HTTPS asset resolver. Performs a synchronous GET and returns
the response body. Other schemes return UnsupportedScheme so this
can sit in a CompositeAssetResolver alongside FS / asset-service resolvers.
Defaults: 10-second timeout, 64 MiB max body, no per-request retry.
Use HttpAssetResolver::with_agent to customise.
Fields§
§max_body_bytes: usizeCap on response body size to avoid loading hostile servers’ runaway responses.
Implementations§
Source§impl HttpAssetResolver
impl HttpAssetResolver
pub fn new() -> Self
pub fn with_agent(agent: Agent) -> Self
pub fn with_max_body_bytes(self, n: usize) -> Self
Trait Implementations§
Source§impl AssetResolver for HttpAssetResolver
impl AssetResolver for HttpAssetResolver
Source§fn fetch(&self, uri: &str) -> Result<Vec<u8>, AssetError>
fn fetch(&self, uri: &str) -> Result<Vec<u8>, AssetError>
Fetch the bytes referenced by
uri. The URI can be a relative or
absolute path, an http:// / https:// URL, an asset-service
reference, or anything else a caller-supplied resolver knows how to handle.Source§fn resolve_id(&self, _id: &str) -> Option<String>
fn resolve_id(&self, _id: &str) -> Option<String>
Resolve a bare asset
id (no path, no extension — e.g. an asset
service’s UUID) to a URI that fetch can load. A filesystem
resolver searches its root recursively for a file whose stem matches;
resolvers that can’t map an id return None (the default). Used as a
fallback for {% media id="…" /%} when the id isn’t a file sitting
directly in the asset root.Auto Trait Implementations§
impl !RefUnwindSafe for HttpAssetResolver
impl !UnwindSafe for HttpAssetResolver
impl Forget for HttpAssetResolver
impl Freeze for HttpAssetResolver
impl Move for HttpAssetResolver
impl Send for HttpAssetResolver
impl Sync for HttpAssetResolver
impl Unpin for HttpAssetResolver
impl UnsafeUnpin for HttpAssetResolver
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.