pub struct Assets { /* private fields */ }Expand description
Assets stores all the assets required by your project,
including images and fonts.
Implementations§
Source§impl Assets
impl Assets
pub fn new() -> Self
Sourcepub fn dirs(&self) -> &Vec<Dir<'static>>
pub fn dirs(&self) -> &Vec<Dir<'static>>
Returns a reference to a vector containing all included directories.
Sourcepub fn add_font(&mut self, font: &[u8]) -> Font
pub fn add_font(&mut self, font: &[u8]) -> Font
Adds a font to the atlas from the provided byte slice and returns the loaded resources::Font resource.
Sourcepub fn add_image(&mut self, image: RgbaImage) -> Image
pub fn add_image(&mut self, image: RgbaImage) -> Image
Adds an image to the atlas from the provided image::RgbaImage and returns the loaded resources::Image resource.
Sourcepub fn add_svg(&mut self, svg: &[u8], scale: f32) -> Image
pub fn add_svg(&mut self, svg: &[u8], scale: f32) -> Image
Adds a svg image to the atlas from the provided byte slice and scale factor and returns the loaded resources::Image resource.
Sourcepub fn load_font(&mut self, file: &str) -> Option<Font>
pub fn load_font(&mut self, file: &str) -> Option<Font>
Loads a font from the given file path and returns an Option containing the resources::Font if successful.
Sourcepub fn load_image(&mut self, file: &str) -> Option<Image>
pub fn load_image(&mut self, file: &str) -> Option<Image>
Loads an image from the given file path and returns an Option containing the resources::Image if successful.
Sourcepub fn load_file(&self, file: &str) -> Option<Vec<u8>>
pub fn load_file(&self, file: &str) -> Option<Vec<u8>>
Loads the contents of the specified file from the search directories, returning its bytes if found.
Sourcepub fn include_assets(&mut self, dir: Dir<'static>)
pub fn include_assets(&mut self, dir: Dir<'static>)
Adds a directory to the list of asset search paths.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Assets
impl !RefUnwindSafe for Assets
impl Send for Assets
impl Sync for Assets
impl Unpin for Assets
impl !UnwindSafe for Assets
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().