Skip to main content

Files

Struct Files 

Source
#[non_exhaustive]
pub struct Files<'a> { pub sound: &'a dyn Fn(&str) -> Bytes, pub sound_shown: &'a dyn Fn(&str) -> String, pub sound_left_out: &'a dyn Fn(&str) -> bool, pub music_dir: &'a str, pub music: Option<&'a dyn Fn(&str) -> Bytes>, }
Expand description

How to read the referenced files, and how errors name them. music is None where the music folder can’t be seen (the game itself, which does no file I/O). Build it with Files::new (ADR-0039).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sound: &'a dyn Fn(&str) -> Bytes

Reads a sound file, by its name in the manifest (e.g. sfx/x.wav).

§sound_shown: &'a dyn Fn(&str) -> String

A sound file’s name as errors show it, by its name in the manifest (e.g. base/audio/sfx/x.wav).

§sound_left_out: &'a dyn Fn(&str) -> bool

Whether this build leaves a sound file out on purpose, by its name in the manifest (a bundle’s left_out): it is then not checked.

§music_dir: &'a str

The music folder’s name as errors show it (e.g. music).

§music: Option<&'a dyn Fn(&str) -> Bytes>

Reads a file in the music folder.

Implementations§

Source§

impl<'a> Files<'a>

Source

pub const fn new( sound: &'a dyn Fn(&str) -> Bytes, sound_shown: &'a dyn Fn(&str) -> String, sound_left_out: &'a dyn Fn(&str) -> bool, music_dir: &'a str, ) -> Self

Sound files read by sound, named in errors by sound_shown, left out where sound_left_out says, and a music folder shown as music_dir that can’t be seen (music is None: with_music changes it).

Source

pub const fn with_music(self, music: Option<&'a dyn Fn(&str) -> Bytes>) -> Self

The files with the music folder read by music: usable in a const item.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Files<'a>

§

impl<'a> !Send for Files<'a>

§

impl<'a> !Sync for Files<'a>

§

impl<'a> !UnwindSafe for Files<'a>

§

impl<'a> Freeze for Files<'a>

§

impl<'a> Unpin for Files<'a>

§

impl<'a> UnsafeUnpin for Files<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.