pub struct Written(/* private fields */);Expand description
The set of paths one generator run wrote.
Implementations§
Source§impl Written
impl Written
Sourcepub fn write(&mut self, path: PathBuf, body: &str) -> Result<()>
pub fn write(&mut self, path: PathBuf, body: &str) -> Result<()>
Write a file verbatim and record the path.
§Errors
Returns an error when the file cannot be written.
Sourcepub fn write_rs(
&mut self,
path: PathBuf,
body: &str,
format: Formatter,
) -> Result<(), WriteError>
pub fn write_rs( &mut self, path: PathBuf, body: &str, format: Formatter, ) -> Result<(), WriteError>
Format generated Rust source with format, write it, and record the
path.
The quote-based emitters return unformatted token text. The generator
passes fmt::rustfmt, which turns it into the canonical committed
form.
§Errors
Returns an error when format rejects the source or the file cannot be
written.
Sourcepub fn prune(&self, dir: &Path, recursive: bool) -> Result<()>
pub fn prune(&self, dir: &Path, recursive: bool) -> Result<()>
Delete every generated file under dir that this run did not write.
A file counts as generated when it opens with BANNER_PREFIX. The
sweep leaves every other file alone, so a hand-written file in an
output directory, or a wrong output path on the command line, does not
lose data.
recursive descends into subdirectories and removes the ones it leaves
empty. A flat sweep stops at the first level, which is what
crates/protocol/generated needs: it holds a namespace subdirectory
that a separate run owns.
§Errors
Returns an error when a directory cannot be read or a file cannot be removed.