pub struct AbsAssetUrl(pub Url);
Expand description

This is a thin wrapper around Url, which is guaranteed to always be an absolute url (including when pointing to a local file).

It’s got a custom Debug implementation which just prints the url, which makes it useful in asset keys

Tuple Fields§

§0: Url

Implementations§

source§

impl AbsAssetUrl

source

pub fn parse(url: impl AsRef<str>) -> Result<Self>

This will also resolve relative local paths

source

pub fn from_file_path(path: impl AsRef<Path>) -> Self

source

pub fn from_directory_path(path: impl AsRef<Path>) -> Self

source

pub fn from_asset_key(key: impl AsRef<str>) -> Result<Self, ParseError>

source

pub fn relative_cache_path(&self) -> String

source

pub fn absolute_cache_path(&self, assets: &AssetCache) -> PathBuf

source

pub fn extension(&self) -> Option<String>

This is always lowercase

source

pub fn extension_is(&self, extension: impl AsRef<str>) -> bool

This is always lowercase

source

pub fn add_extension(&self, extension: &str) -> Self

Appends the extension: test.png -> test.png.hello

source

pub fn file_stem(&self) -> Option<&str>

source

pub fn to_file_path(&self) -> Result<Option<PathBuf>>

source

pub fn resolve( &self, url_or_relative_path: impl AsRef<str> ) -> Result<Self, ParseError>

source

pub fn push(&self, path: impl AsRef<str>) -> Result<Self, ParseError>

This appends [path] to the current path, with a / joining them

source

pub fn join(&self, path: impl AsRef<str>) -> Result<Self, ParseError>

This joins the current url with a relative path. See https://docs.rs/url/latest/url/struct.Url.html#method.join for details how it works

source

pub fn path(&self) -> RelativePathBuf

Returns the decoded path

source

pub fn set_path(&mut self, path: impl AsRef<str>)

source

pub fn relative_path(&self, path: impl AsRef<RelativePath>) -> RelativePathBuf

source

pub fn is_directory(&self) -> bool

source

pub fn as_directory(&self) -> Self

Ensures that this url ends with /, which is interpreted as a “directory” by the Url package

source

pub fn as_file(&self) -> Self

Ensures that this url doesn’t end with /, which is interpreted as a “directory” by the Url package

source

pub fn last_dir_name(&self) -> Option<&str>

For a/b/c.png this returns b

source

pub fn to_download_url(&self, assets: &AssetCache) -> Result<Self, ParseError>

source

pub async fn download_bytes(&self, assets: &AssetCache) -> Result<Vec<u8>>

source

pub async fn download_string(&self, assets: &AssetCache) -> Result<String>

source

pub async fn download_json<T: 'static + Send + DeserializeOwned>( &self, assets: &AssetCache ) -> Result<T>

source

pub async fn download_toml<T: DeserializeOwned>( &self, assets: &AssetCache ) -> Result<T>

Trait Implementations§

source§

impl Clone for AbsAssetUrl

source§

fn clone(&self) -> AbsAssetUrl

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AbsAssetUrl

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for AbsAssetUrl

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for AbsAssetUrl

source§

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

Formats the value using the given formatter. Read more
source§

impl From<AbsAssetUrl> for AssetUrl

source§

fn from(value: AbsAssetUrl) -> Self

Converts to this type from the input type.
source§

impl From<AbsAssetUrl> for String

source§

fn from(value: AbsAssetUrl) -> Self

Converts to this type from the input type.
source§

impl<T: GetAssetType> From<AbsAssetUrl> for TypedAssetUrl<T>

source§

fn from(value: AbsAssetUrl) -> Self

Converts to this type from the input type.
source§

impl From<PathBuf> for AbsAssetUrl

source§

fn from(value: PathBuf) -> Self

Converts to this type from the input type.
source§

impl Hash for AbsAssetUrl

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<AbsAssetUrl> for AbsAssetUrl

source§

fn eq(&self, other: &AbsAssetUrl) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for AbsAssetUrl

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl SyncAssetKey<AbsAssetUrl> for ContentBaseUrlKey

source§

fn load(&self, assets: AssetCache) -> AbsAssetUrl

source§

impl SyncAssetKey<AbsAssetUrl> for ServerBaseUrlKey

source§

fn load(&self, _assets: AssetCache) -> AbsAssetUrl

source§

impl Eq for AbsAssetUrl

source§

impl StructuralEq for AbsAssetUrl

source§

impl StructuralPartialEq for AbsAssetUrl

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for Twhere T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

fn type_name(&self) -> &'static str

Gets the type name of self
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,