pub struct AssetSourceBuilder {
pub reader: 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: Box<dyn FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync>The ErasedAssetReader to use on the unprocessed asset.
writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync>>The ErasedAssetWriter to use on the unprocessed asset.
watcher: Option<Box<dyn FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync>>The AssetWatcher to use for unprocessed assets, if any.
processed_reader: Option<Box<dyn FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync>>The ErasedAssetReader to use for processed assets.
processed_writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync>>The ErasedAssetWriter to use for processed assets.
processed_watcher: Option<Box<dyn FnMut(Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>> + Send + Sync>>The AssetWatcher to use for processed assets, if any.
watch_warning: Option<&'static str>The warning message to display when watching an unprocessed asset fails.
processed_watch_warning: Option<&'static str>The warning message to display when watching a processed asset fails.
Implementations§
Source§impl AssetSourceBuilder
impl AssetSourceBuilder
Sourcepub fn new(
reader: impl FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync + 'static,
) -> AssetSourceBuilder
pub fn new( reader: impl FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync + 'static, ) -> AssetSourceBuilder
Creates a new builder, starting with the provided reader.
Sourcepub fn build(
&mut self,
id: AssetSourceId<'static>,
watch: bool,
watch_processed: bool,
) -> AssetSource
pub fn build( &mut self, id: AssetSourceId<'static>, watch: bool, watch_processed: bool, ) -> 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.
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>, 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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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