@@ -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)
@@ -353,18 +353,18 @@ pub struct WriterContext<'a> {
353353 /// The underlying writer of all writes for the [`Process`].
354354 writer : & ' a dyn ErasedAssetWriter ,
355355 /// The context for initializing a write.
356- // We use a Mutex to avoid requiring a mutable borrow for `write_multiple `. See `write_multiple `
356+ // We use a Mutex to avoid requiring a mutable borrow for `write_partial `. See `write_partial `
357357 // for more details.
358358 init_context : Mutex < WriteInitContext < ' a > > ,
359359 /// The number of writes that have been fully finished.
360360 ///
361361 /// Note we use an `AtomicU32` instead of a u32 so that writes (and therefore finish's) don't
362- /// need to be synchronous. We use a mutable borrow so that single -writes can just update the
362+ /// need to be synchronous. We use a mutable borrow so that full -writes can just update the
363363 /// value without atomics.
364364 finished_writes : & ' a mut AtomicU32 ,
365365 /// The meta object to write when writing a single file. Must be set to [`Some`] when writing a
366- /// single file.
367- single_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
366+ /// "full" file.
367+ full_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
368368 /// The path of the asset being processed.
369369 path : & ' a AssetPath < ' static > ,
370370}
@@ -373,7 +373,7 @@ pub struct WriterContext<'a> {
373373struct WriteInitContext < ' a > {
374374 /// The number of writes that have been started.
375375 started_writes : & ' a mut u32 ,
376- /// The set of currently started `write_multiple` instances.
376+ /// The set of currently started [`WriterContext::write_partial`] instances.
377377 ///
378378 /// This protects us from starting writes for the same path multiple times.
379379 started_paths : HashSet < PathBuf > ,
@@ -384,7 +384,7 @@ impl<'a> WriterContext<'a> {
384384 writer : & ' a dyn ErasedAssetWriter ,
385385 started_writes : & ' a mut u32 ,
386386 finished_writes : & ' a mut AtomicU32 ,
387- single_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
387+ full_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
388388 path : & ' a AssetPath < ' static > ,
389389 ) -> Self {
390390 Self {
@@ -394,23 +394,23 @@ impl<'a> WriterContext<'a> {
394394 started_paths : HashSet :: new ( ) ,
395395 } ) ,
396396 finished_writes,
397- single_meta ,
397+ full_meta ,
398398 path,
399399 }
400400 }
401401
402402 /// Start writing a single output file, which can be loaded with the `load_settings`.
403403 ///
404- /// Returns an error if you have previously called [`Self::write_multiple `].
405- pub async fn write_single ( self ) -> Result < SingleWriter < ' a > , ProcessError > {
404+ /// Returns an error if you have previously called [`Self::write_partial `].
405+ pub async fn write_full ( self ) -> Result < FullWriter < ' a > , ProcessError > {
406406 let started_writes = self
407407 . init_context
408408 . into_inner ( )
409409 . unwrap_or_else ( PoisonError :: into_inner)
410410 . started_writes ;
411411 if * started_writes != 0 {
412412 return Err ( ProcessError :: InvalidProcessOutput (
413- InvalidProcessOutput :: SingleFileAfterMultipleFile ,
413+ InvalidProcessOutput :: FullFileAfterPartialFile ,
414414 ) ) ;
415415 }
416416 * started_writes = 1 ;
@@ -421,21 +421,19 @@ impl<'a> WriterContext<'a> {
421421 err,
422422 }
423423 } ) ?;
424- Ok ( SingleWriter {
424+ Ok ( FullWriter {
425425 writer,
426426 finished_writes : self . finished_writes . get_mut ( ) ,
427427 path : self . path ,
428- single_meta : self . single_meta ,
428+ meta : self . full_meta ,
429429 } )
430430 }
431431
432- /// Start writing one of multiple output file, which can be loaded with the `load_settings`.
433- ///
434- /// Returns an error if you have previously started writing a single file.
432+ /// Start writing one of multiple output files, which can be loaded with the `load_settings`.
435433 // Note: It would be nice to take this by a mutable reference instead. However, doing so would
436434 // mean that the returned value would be tied to a "mutable reference lifetime", meaning we
437- // could not use more than one `MultipleWriter ` instance concurrently.
438- pub async fn write_multiple ( & self , file : & Path ) -> Result < MultipleWriter < ' _ > , ProcessError > {
435+ // could not use more than one `PartialWriter ` instance concurrently.
436+ pub async fn write_partial ( & self , file : & Path ) -> Result < PartialWriter < ' _ > , ProcessError > {
439437 // Do all the validation in a scope so we don't hold the init_context for too long.
440438 {
441439 let mut init_context = self
@@ -445,7 +443,7 @@ impl<'a> WriterContext<'a> {
445443 // Check whether this path is valid first so that we don't mark the write as started
446444 // when it hasn't.
447445 if !init_context. started_paths . insert ( file. to_path_buf ( ) ) {
448- return Err ( InvalidProcessOutput :: RepeatedMultipleWriteToSamePath (
446+ return Err ( InvalidProcessOutput :: RepeatedPartialWriteToSamePath (
449447 file. to_path_buf ( ) ,
450448 )
451449 . into ( ) ) ;
@@ -469,7 +467,7 @@ impl<'a> WriterContext<'a> {
469467 path : path. clone_owned ( ) ,
470468 err,
471469 } ) ?;
472- Ok ( MultipleWriter {
470+ Ok ( PartialWriter {
473471 meta_writer : self . writer ,
474472 writer,
475473 finished_writes : & * self . finished_writes ,
@@ -482,32 +480,34 @@ impl<'a> WriterContext<'a> {
482480#[ derive( Error , Debug ) ]
483481pub enum InvalidProcessOutput {
484482 /// The processor didn't start a write at all.
485- #[ error( "The processor never started writing a file (never called `write_single` or `write_multiple`)" ) ]
483+ #[ error(
484+ "The processor never started writing a file (never called `write_full` or `write_partial`)"
485+ ) ]
486486 NoWriter ,
487487 /// The processor started a write but never finished it.
488488 #[ error( "The processor started writing a file, but never called `finish`" ) ]
489489 UnfinishedWriter ,
490- /// The processor started at least one multiple write, then continued with a single write.
491- #[ error( "The processor called `write_single ` after already calling `write_multiple `" ) ]
492- SingleFileAfterMultipleFile ,
493- /// The processor started a multiple write with the same path multiple times.
494- #[ error( "The processor called `write_multiple ` more than once with the same path" ) ]
495- RepeatedMultipleWriteToSamePath ( PathBuf ) ,
490+ /// The processor started at least one partial write, then continued with a full write.
491+ #[ error( "The processor called `write_full ` after already calling `write_partial `" ) ]
492+ FullFileAfterPartialFile ,
493+ /// The processor started a partial write with the same path multiple times.
494+ #[ error( "The processor called `write_partial ` more than once with the same path" ) ]
495+ RepeatedPartialWriteToSamePath ( PathBuf ) ,
496496}
497497
498498/// The writer for a [`Process`] writing a single file (at the same path as the unprocessed asset).
499- pub struct SingleWriter < ' a > {
499+ pub struct FullWriter < ' a > {
500500 /// The writer to write to.
501501 writer : Box < Writer > ,
502502 /// The counter for finished writes that will be incremented when the write completes.
503503 finished_writes : & ' a mut u32 ,
504504 /// The meta object that will be assigned on [`Self::finish`].
505- single_meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
505+ meta : & ' a mut Option < Box < dyn AssetMetaDyn > > ,
506506 /// The path of the asset being written.
507507 path : & ' a AssetPath < ' static > ,
508508}
509509
510- impl SingleWriter < ' _ > {
510+ impl FullWriter < ' _ > {
511511 /// Finishes a write and indicates that the written asset should be loaded with the provided
512512 /// loader and the provided settings for that loader.
513513 ///
@@ -531,8 +531,8 @@ impl SingleWriter<'_> {
531531
532532 // This should always be none, since we consumed the WriterContext, and we consume the
533533 // only borrow here.
534- assert ! ( self . single_meta . is_none( ) ) ;
535- * self . single_meta = Some ( Box :: new ( output_meta) ) ;
534+ assert ! ( self . meta . is_none( ) ) ;
535+ * self . meta = Some ( Box :: new ( output_meta) ) ;
536536
537537 // Make sure to increment finished writes at the very end, so that we only count it, once
538538 // the future is finished anyway.
@@ -541,8 +541,9 @@ impl SingleWriter<'_> {
541541 }
542542}
543543
544- /// A writer for a [`Process`] writing multiple files (as children of the unprocessed asset path).
545- pub struct MultipleWriter < ' a > {
544+ /// A writer for a [`Process`] writing multiple partial files (as children of the unprocessed asset
545+ /// path).
546+ pub struct PartialWriter < ' a > {
546547 /// The writer to use when writing the meta file for this file.
547548 meta_writer : & ' a dyn ErasedAssetWriter ,
548549 /// The writer to write to.
@@ -555,7 +556,7 @@ pub struct MultipleWriter<'a> {
555556 path : AssetPath < ' static > ,
556557}
557558
558- impl MultipleWriter < ' _ > {
559+ impl PartialWriter < ' _ > {
559560 /// Finishes a write and indicates that the written asset should be loaded with the provided
560561 /// loader and the provided settings for that loader.
561562 ///
@@ -598,29 +599,29 @@ impl MultipleWriter<'_> {
598599 }
599600}
600601
601- impl Deref for SingleWriter < ' _ > {
602+ impl Deref for FullWriter < ' _ > {
602603 type Target = Writer ;
603604
604605 fn deref ( & self ) -> & Self :: Target {
605606 self . writer . as_ref ( )
606607 }
607608}
608609
609- impl DerefMut for SingleWriter < ' _ > {
610+ impl DerefMut for FullWriter < ' _ > {
610611 fn deref_mut ( & mut self ) -> & mut Self :: Target {
611612 self . writer . as_mut ( )
612613 }
613614}
614615
615- impl Deref for MultipleWriter < ' _ > {
616+ impl Deref for PartialWriter < ' _ > {
616617 type Target = Writer ;
617618
618619 fn deref ( & self ) -> & Self :: Target {
619620 self . writer . as_ref ( )
620621 }
621622}
622623
623- impl DerefMut for MultipleWriter < ' _ > {
624+ impl DerefMut for PartialWriter < ' _ > {
624625 fn deref_mut ( & mut self ) -> & mut Self :: Target {
625626 self . writer . as_mut ( )
626627 }
0 commit comments