pub struct Asset<T: AssetTrait> {
pub id: AssetId<T>,
pub path: Vec<String>,
pub data: T,
}Expand description
An asset with its id. Serialized as such for the wire; files on disk use
AssetOnDisk, which takes the id from the file name.
Fields§
§id: AssetId<T>§path: Vec<String>§data: TImplementations§
Source§impl<T: AssetTrait> Asset<T>
impl<T: AssetTrait> Asset<T>
pub fn new(path: Vec<String>) -> Self
pub fn get(id: AssetId<T>, collections: &Collections) -> Option<Arc<Self>>
pub fn get_asset_from_index( index: usize, collections: &Collections, ) -> Option<Arc<Self>>
pub fn all(collections: &Collections) -> Vec<Arc<Asset<T>>>
Sourcepub fn read(reader: impl Read, id: AssetId<T>) -> Result<Arc<Self>, Error>
pub fn read(reader: impl Read, id: AssetId<T>) -> Result<Arc<Self>, Error>
Reads an asset from its JSON file.
pub fn into_json(self) -> Result<String, Error>
pub fn dir(&self) -> Vec<String>
pub fn name(&self) -> &str
pub fn change_dir(&mut self, new_dir: &[String])
Trait Implementations§
Source§impl<T: AssetTrait> Default for Asset<T>
impl<T: AssetTrait> Default for Asset<T>
Source§impl<'de, T> Deserialize<'de> for Asset<T>
impl<'de, T> Deserialize<'de> for Asset<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq + AssetTrait> Eq for Asset<T>
impl<T: PartialEq + AssetTrait> StructuralPartialEq for Asset<T>
Auto Trait Implementations§
impl<T> Freeze for Asset<T>
impl<T> RefUnwindSafe for Asset<T>
impl<T> Send for Asset<T>
impl<T> Sync for Asset<T>
impl<T> Unpin for Asset<T>
impl<T> UnsafeUnpin for Asset<T>
impl<T> UnwindSafe for Asset<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DebugAny for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more