Skip to main content

Written

Struct Written 

Source
pub struct Written(/* private fields */);
Expand description

The set of paths one generator run wrote.

Implementations§

Source§

impl Written

Source

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.

Source

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.

Source

pub fn contains(&self, path: &Path) -> bool

True when this run wrote path.

Source

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.

Trait Implementations§

Source§

impl Debug for Written

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Written

Source§

fn default() -> Written

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.