refactor(tvix/nix-compat/derivation): use writer.write_all

This is more concise than a io::copy of a Cursor to bytes, and we have
everything to be written in memory.

Change-Id: I81f34666aa61aef4e16b33423ce4a69c3781efc3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8997
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-07-31 23:12:31 +02:00 committed by clbot
parent 737a6ca01e
commit 779fad29a1
2 changed files with 10 additions and 8 deletions

View file

@ -47,7 +47,7 @@ impl Derivation {
///
/// The only errors returns are these when writing to the passed writer.
pub fn serialize(&self, writer: &mut impl std::io::Write) -> Result<(), io::Error> {
io::copy(&mut io::Cursor::new(write::DERIVATION_PREFIX), writer)?;
writer.write_all(write::DERIVATION_PREFIX.as_bytes())?;
write::write_char(writer, write::PAREN_OPEN)?;
write::write_outputs(writer, &self.outputs)?;