pub fn check_output(output_path: &Path, code: &str) -> Result<Drift>Expand description
Compare code with the content of output_path and report the difference.
This reads the file and writes nothing, so a caller can gate a build on stale
generated code. The comparison is exact, because the generator formats every
output through prettyplease and therefore produces one byte sequence for one
input.
The comparison reads bytes and not text. Generated Rust is always UTF-8, so a
file that is not gives Drift::Differs. That is what the file is, and it
also keeps a hand-edited or truncated file on the drift path where the remedy
applies, rather than on the error path where it does not.
ยงErrors
Returns Error::ReadOutput when the file exists and cannot be read, for
example a directory in place of a file. An absent file gives Drift::Absent
and not an error, because generation creates it.