@@ -206,7 +206,7 @@ where
206206
207207 let saver = & self . saver ;
208208 let saver_settings = & settings. saver_settings ;
209- let mut writer = writer_context. write_single ( ) . await ?;
209+ let mut writer = writer_context. write_full ( ) . await ?;
210210
211211 let output_settings = saver
212212 . save ( & mut * writer, saved_asset, saver_settings)
@@ -347,18 +347,18 @@ pub struct WriterContext<'a> {
347347 /// The underlying writer of all writes for the [`Process`].
348348 writer : & ' a dyn ErasedAssetWriter ,
349349 /// The context for initializing a write.
350- // We use a Mutex to avoid requiring a mutable borrow for `write_multiple `. See `write_multiple `
350+ // We use a Mutex to avoid requiring a mutable borrow for `write_partial `. See `write_partial `
351351 // for more details.
352352 init_context : Mutex < WriteInitContext < ' a > > ,
353353 /// The number of writes that have been fully finished.
354354 ///
355355 /// Note we use an `AtomicU32` instead of a u32 so that writes (and therefore finish's) don't
356- /// need to be synchronous. We use a mutable borrow so that single -writes can just update the
356+ /// need to be synchronous. We use a mutable borrow so that full -writes can just update the
357357 /// value without atomics.
358358 finished_writes : & ' a mut AtomicU32 ,
359359 /// The meta object to write when writing a single file. Must be set to [`Some`] when writing a
360- /// single file.
361- single_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
360+ /// "full" file.
361+ full_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
362362 /// The path of the asset being processed.
363363 path : & ' a AssetPath < ' static > ,
364364}
@@ -367,7 +367,7 @@ pub struct WriterContext<'a> {
367367struct WriteInitContext < ' a > {
368368 /// The number of writes that have been started.
369369 started_writes : & ' a mut u32 ,
370- /// The set of currently started `write_multiple` instances.
370+ /// The set of currently started [`WriterContext::write_partial`] instances.
371371 ///
372372 /// This protects us from starting writes for the same path multiple times.
373373 started_paths : HashSet < PathBuf > ,
@@ -378,7 +378,7 @@ impl<'a> WriterContext<'a> {
378378 writer : & ' a dyn ErasedAssetWriter ,
379379 started_writes : & ' a mut u32 ,
380380 finished_writes : & ' a mut AtomicU32 ,
381- single_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
381+ full_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
382382 path : & ' a AssetPath < ' static > ,
383383 ) -> Self {
384384 Self {
@@ -388,23 +388,23 @@ impl<'a> WriterContext<'a> {
388388 started_paths : HashSet :: new ( ) ,
389389 } ) ,
390390 finished_writes,
391- single_meta ,
391+ full_meta ,
392392 path,
393393 }
394394 }
395395
396396 /// Start writing a single output file, which can be loaded with the `load_settings`.
397397 ///
398- /// Returns an error if you have previously called [`Self::write_multiple `].
399- pub async fn write_single ( self ) -> Result < SingleWriter < ' a > , ProcessError > {
398+ /// Returns an error if you have previously called [`Self::write_partial `].
399+ pub async fn write_full ( self ) -> Result < FullWriter < ' a > , ProcessError > {
400400 let started_writes = self
401401 . init_context
402402 . into_inner ( )
403403 . unwrap_or_else ( PoisonError :: into_inner)
404404 . started_writes ;
405405 if * started_writes != 0 {
406406 return Err ( ProcessError :: InvalidProcessOutput (
407- InvalidProcessOutput :: SingleFileAfterMultipleFile ,
407+ InvalidProcessOutput :: FullFileAfterPartialFile ,
408408 ) ) ;
409409 }
410410 * started_writes = 1 ;
@@ -415,21 +415,19 @@ impl<'a> WriterContext<'a> {
415415 err,
416416 }
417417 } ) ?;
418- Ok ( SingleWriter {
418+ Ok ( FullWriter {
419419 writer,
420420 finished_writes : self . finished_writes . get_mut ( ) ,
421421 path : self . path ,
422- single_meta : self . single_meta ,
422+ meta : self . full_meta ,
423423 } )
424424 }
425425
426- /// Start writing one of multiple output file, which can be loaded with the `load_settings`.
427- ///
428- /// Returns an error if you have previously started writing a single file.
426+ /// Start writing one of multiple output files, which can be loaded with the `load_settings`.
429427 // Note: It would be nice to take this by a mutable reference instead. However, doing so would
430428 // mean that the returned value would be tied to a "mutable reference lifetime", meaning we
431- // could not use more than one `MultipleWriter ` instance concurrently.
432- pub async fn write_multiple ( & self , file : & Path ) -> Result < MultipleWriter < ' _ > , ProcessError > {
429+ // could not use more than one `PartialWriter ` instance concurrently.
430+ pub async fn write_partial ( & self , file : & Path ) -> Result < PartialWriter < ' _ > , ProcessError > {
433431 // Do all the validation in a scope so we don't hold the init_context for too long.
434432 {
435433 let mut init_context = self
@@ -439,7 +437,7 @@ impl<'a> WriterContext<'a> {
439437 // Check whether this path is valid first so that we don't mark the write as started
440438 // when it hasn't.
441439 if !init_context. started_paths . insert ( file. to_path_buf ( ) ) {
442- return Err ( InvalidProcessOutput :: RepeatedMultipleWriteToSamePath (
440+ return Err ( InvalidProcessOutput :: RepeatedPartialWriteToSamePath (
443441 file. to_path_buf ( ) ,
444442 )
445443 . into ( ) ) ;
@@ -463,7 +461,7 @@ impl<'a> WriterContext<'a> {
463461 path : path. clone_owned ( ) ,
464462 err,
465463 } ) ?;
466- Ok ( MultipleWriter {
464+ Ok ( PartialWriter {
467465 meta_writer : self . writer ,
468466 writer,
469467 finished_writes : & * self . finished_writes ,
@@ -476,32 +474,34 @@ impl<'a> WriterContext<'a> {
476474#[ derive( Error , Debug ) ]
477475pub enum InvalidProcessOutput {
478476 /// The processor didn't start a write at all.
479- #[ error( "The processor never started writing a file (never called `write_single` or `write_multiple`)" ) ]
477+ #[ error(
478+ "The processor never started writing a file (never called `write_full` or `write_partial`)"
479+ ) ]
480480 NoWriter ,
481481 /// The processor started a write but never finished it.
482482 #[ error( "The processor started writing a file, but never called `finish`" ) ]
483483 UnfinishedWriter ,
484- /// The processor started at least one multiple write, then continued with a single write.
485- #[ error( "The processor called `write_single ` after already calling `write_multiple `" ) ]
486- SingleFileAfterMultipleFile ,
487- /// The processor started a multiple write with the same path multiple times.
488- #[ error( "The processor called `write_multiple ` more than once with the same path" ) ]
489- RepeatedMultipleWriteToSamePath ( PathBuf ) ,
484+ /// The processor started at least one partial write, then continued with a full write.
485+ #[ error( "The processor called `write_full ` after already calling `write_partial `" ) ]
486+ FullFileAfterPartialFile ,
487+ /// The processor started a partial write with the same path multiple times.
488+ #[ error( "The processor called `write_partial ` more than once with the same path" ) ]
489+ RepeatedPartialWriteToSamePath ( PathBuf ) ,
490490}
491491
492492/// The writer for a [`Process`] writing a single file (at the same path as the unprocessed asset).
493- pub struct SingleWriter < ' a > {
493+ pub struct FullWriter < ' a > {
494494 /// The writer to write to.
495495 writer : Box < Writer > ,
496496 /// The counter for finished writes that will be incremented when the write completes.
497497 finished_writes : & ' a mut u32 ,
498498 /// The meta object that will be assigned on [`Self::finish`].
499- single_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
499+ meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
500500 /// The path of the asset being written.
501501 path : & ' a AssetPath < ' static > ,
502502}
503503
504- impl SingleWriter < ' _ > {
504+ impl FullWriter < ' _ > {
505505 /// Finishes a write and indicates that the written asset should be loaded with the provided
506506 /// loader and the provided settings for that loader.
507507 ///
@@ -525,8 +525,8 @@ impl SingleWriter<'_> {
525525
526526 // This should always be none, since we consumed the WriterContext, and we consume the
527527 // only borrow here.
528- assert ! ( self . single_meta . is_none( ) ) ;
529- * self . single_meta = Some ( Box :: new ( output_meta) ) ;
528+ assert ! ( self . meta . is_none( ) ) ;
529+ * self . meta = Some ( Box :: new ( output_meta) ) ;
530530
531531 // Make sure to increment finished writes at the very end, so that we only count it, once
532532 // the future is finished anyway.
@@ -535,8 +535,9 @@ impl SingleWriter<'_> {
535535 }
536536}
537537
538- /// A writer for a [`Process`] writing multiple files (as children of the unprocessed asset path).
539- pub struct MultipleWriter < ' a > {
538+ /// A writer for a [`Process`] writing multiple partial files (as children of the unprocessed asset
539+ /// path).
540+ pub struct PartialWriter < ' a > {
540541 /// The writer to use when writing the meta file for this file.
541542 meta_writer : & ' a dyn ErasedAssetWriter ,
542543 /// The writer to write to.
@@ -549,7 +550,7 @@ pub struct MultipleWriter<'a> {
549550 path : AssetPath < ' static > ,
550551}
551552
552- impl MultipleWriter < ' _ > {
553+ impl PartialWriter < ' _ > {
553554 /// Finishes a write and indicates that the written asset should be loaded with the provided
554555 /// loader and the provided settings for that loader.
555556 ///
@@ -592,29 +593,29 @@ impl MultipleWriter<'_> {
592593 }
593594}
594595
595- impl Deref for SingleWriter < ' _ > {
596+ impl Deref for FullWriter < ' _ > {
596597 type Target = Writer ;
597598
598599 fn deref ( & self ) -> & Self :: Target {
599600 self . writer . as_ref ( )
600601 }
601602}
602603
603- impl DerefMut for SingleWriter < ' _ > {
604+ impl DerefMut for FullWriter < ' _ > {
604605 fn deref_mut ( & mut self ) -> & mut Self :: Target {
605606 self . writer . as_mut ( )
606607 }
607608}
608609
609- impl Deref for MultipleWriter < ' _ > {
610+ impl Deref for PartialWriter < ' _ > {
610611 type Target = Writer ;
611612
612613 fn deref ( & self ) -> & Self :: Target {
613614 self . writer . as_ref ( )
614615 }
615616}
616617
617- impl DerefMut for MultipleWriter < ' _ > {
618+ impl DerefMut for PartialWriter < ' _ > {
618619 fn deref_mut ( & mut self ) -> & mut Self :: Target {
619620 self . writer . as_mut ( )
620621 }
0 commit comments