pub struct AssetSourceBuilder {
pub reader: Option<Box<dyn FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync>>,
pub writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + 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 ErasedAssetReader> + Send + Sync>>,
pub processed_writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + 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 ErasedAssetReader> + Send + Sync>>
§writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync>>
§watcher: Option<Box<dyn FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync>>
§processed_reader: Option<Box<dyn FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync>>
§processed_writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + 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 ErasedAssetReader> + Send + Sync + 'static,
) -> Self
pub fn with_reader( self, reader: impl FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync + 'static, ) -> Self
Will use the given reader
function to construct unprocessed AssetReader
instances.
Sourcepub fn with_writer(
self,
writer: impl FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync + 'static,
) -> Self
pub fn with_writer( self, writer: impl FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync + 'static, ) -> Self
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,
) -> Self
pub fn with_watcher( self, watcher: impl FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync + 'static, ) -> Self
Will use the given watcher
function to construct unprocessed AssetWatcher
instances.
Sourcepub fn with_processed_reader(
self,
reader: impl FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync + 'static,
) -> Self
pub fn with_processed_reader( self, reader: impl FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync + 'static, ) -> Self
Will use the given reader
function to construct processed AssetReader
instances.
Sourcepub fn with_processed_writer(
self,
writer: impl FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync + 'static,
) -> Self
pub fn with_processed_writer( self, writer: impl FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync + 'static, ) -> Self
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,
) -> Self
pub fn with_processed_watcher( self, watcher: impl FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync + 'static, ) -> Self
Will use the given watcher
function to construct processed AssetWatcher
instances.
Sourcepub fn with_watch_warning(self, warning: &'static str) -> Self
pub fn with_watch_warning(self, warning: &'static str) -> Self
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) -> Self
pub fn with_processed_watch_warning(self, warning: &'static str) -> Self
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>) -> Self
pub fn platform_default(path: &str, processed_path: Option<&str>) -> Self
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 Freeze for AssetSourceBuilder
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> 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<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
Creates Self
using default()
.
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 more