Struct bevy::asset::io::AssetSourceBuilder
source · pub struct AssetSourceBuilder {
pub reader: Option<Box<dyn FnMut() -> Box<dyn AssetReader> + Send + Sync>>,
pub writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync>>,
pub watcher: Option<Box<dyn FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync>>,
pub processed_reader: Option<Box<dyn FnMut() -> Box<dyn AssetReader> + Send + Sync>>,
pub processed_writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync>>,
pub processed_watcher: Option<Box<dyn FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync>>,
pub watch_warning: Option<&'static str>,
pub processed_watch_warning: Option<&'static str>,
}
Expand description
Metadata about an “asset source”, such as how to construct the AssetReader
and AssetWriter
for the source,
and whether or not the source is processed.
Fields§
§reader: Option<Box<dyn FnMut() -> Box<dyn AssetReader> + Send + Sync>>
§writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync>>
§watcher: Option<Box<dyn FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync>>
§processed_reader: Option<Box<dyn FnMut() -> Box<dyn AssetReader> + Send + Sync>>
§processed_writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync>>
§processed_watcher: Option<Box<dyn FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync>>
§watch_warning: Option<&'static str>
§processed_watch_warning: Option<&'static str>
Implementations§
source§impl AssetSourceBuilder
impl AssetSourceBuilder
sourcepub fn build(
&mut self,
id: AssetSourceId<'static>,
watch: bool,
watch_processed: bool
) -> Option<AssetSource>
pub fn build( &mut self, id: AssetSourceId<'static>, watch: bool, watch_processed: bool ) -> Option<AssetSource>
Builds a new AssetSource
with the given id
. If watch
is true, the unprocessed source will watch for changes.
If watch_processed
is true, the processed source will watch for changes.
sourcepub fn with_reader(
self,
reader: impl FnMut() -> Box<dyn AssetReader> + Send + Sync + 'static
) -> AssetSourceBuilder
pub fn with_reader( self, reader: impl FnMut() -> Box<dyn AssetReader> + Send + Sync + 'static ) -> AssetSourceBuilder
Will use the given reader
function to construct unprocessed AssetReader
instances.
sourcepub fn with_writer(
self,
writer: impl FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static
) -> AssetSourceBuilder
pub fn with_writer( self, writer: impl FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static ) -> AssetSourceBuilder
Will use the given writer
function to construct unprocessed AssetWriter
instances.
sourcepub fn with_watcher(
self,
watcher: impl FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync + 'static
) -> AssetSourceBuilder
pub fn with_watcher( self, watcher: impl FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync + 'static ) -> AssetSourceBuilder
Will use the given watcher
function to construct unprocessed AssetWatcher
instances.
sourcepub fn with_processed_reader(
self,
reader: impl FnMut() -> Box<dyn AssetReader> + Send + Sync + 'static
) -> AssetSourceBuilder
pub fn with_processed_reader( self, reader: impl FnMut() -> Box<dyn AssetReader> + Send + Sync + 'static ) -> AssetSourceBuilder
Will use the given reader
function to construct processed AssetReader
instances.
sourcepub fn with_processed_writer(
self,
writer: impl FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static
) -> AssetSourceBuilder
pub fn with_processed_writer( self, writer: impl FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static ) -> AssetSourceBuilder
Will use the given writer
function to construct processed AssetWriter
instances.
sourcepub fn with_processed_watcher(
self,
watcher: impl FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync + 'static
) -> AssetSourceBuilder
pub fn with_processed_watcher( self, watcher: impl FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync + 'static ) -> AssetSourceBuilder
Will use the given watcher
function to construct processed AssetWatcher
instances.
sourcepub fn with_watch_warning(self, warning: &'static str) -> AssetSourceBuilder
pub fn with_watch_warning(self, warning: &'static str) -> AssetSourceBuilder
Enables a warning for the unprocessed source watcher, which will print when watching is enabled and the unprocessed source doesn’t have a watcher.
sourcepub fn with_processed_watch_warning(
self,
warning: &'static str
) -> AssetSourceBuilder
pub fn with_processed_watch_warning( self, warning: &'static str ) -> AssetSourceBuilder
Enables a warning for the processed source watcher, which will print when watching is enabled and the processed source doesn’t have a watcher.
sourcepub fn platform_default(
path: &str,
processed_path: Option<&str>
) -> AssetSourceBuilder
pub fn platform_default( path: &str, processed_path: Option<&str> ) -> AssetSourceBuilder
Returns a builder containing the “platform default source” for the given path
and processed_path
.
For most platforms, this will use FileAssetReader
/ FileAssetWriter
,
but some platforms (such as Android) have their own default readers / writers / watchers.
Trait Implementations§
source§impl Default for AssetSourceBuilder
impl Default for AssetSourceBuilder
source§fn default() -> AssetSourceBuilder
fn default() -> AssetSourceBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for AssetSourceBuilder
impl Send for AssetSourceBuilder
impl Sync for AssetSourceBuilder
impl Unpin for AssetSourceBuilder
impl !UnwindSafe for AssetSourceBuilder
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.