refactor(tvix/nix-compat/derivation): simplify
Let the escape function only take care of string escaping, not quoting. Let write_array_elements always quote and escape strings it consumes. Move the business of writing additional wrapping characters around it to the caller. Change-Id: Ib8dea69c409561b49862c531ba5a3fe6c2f061f8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8993 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
79531c3dab
commit
34b7620764
3 changed files with 51 additions and 64 deletions
|
|
@ -5,6 +5,7 @@ use bstr::BString;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::io;
|
||||
|
||||
mod errors;
|
||||
mod escape;
|
||||
|
|
@ -45,8 +46,8 @@ impl Derivation {
|
|||
/// write the Derivation to the given [std::io::Write], in ATerm format.
|
||||
///
|
||||
/// The only errors returns are these when writing to the passed writer.
|
||||
pub fn serialize(&self, writer: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||
write::write_str(writer, write::DERIVATION_PREFIX)?;
|
||||
pub fn serialize(&self, writer: &mut impl std::io::Write) -> Result<(), io::Error> {
|
||||
io::copy(&mut io::Cursor::new(write::DERIVATION_PREFIX), writer)?;
|
||||
write::write_char(writer, write::PAREN_OPEN)?;
|
||||
|
||||
write::write_outputs(writer, &self.outputs)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue