From 9d7c3ee877837070c51760cb621bc409c6d0f6a7 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 13 Feb 2021 23:13:20 +0100 Subject: feat(users/Profpatsch/netencode): add env-splice-record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s the inverse of record-splice-env! It sucks up the environment and prints it as a netencode dict! Only the utf-8 clean parts at least. Change-Id: I96c19fc5ea3a67a23e238f15f4d0fa783081859c Reviewed-on: https://cl.tvl.fyi/c/depot/+/2527 Tested-by: BuildkiteCI Reviewed-by: Profpatsch --- users/Profpatsch/netencode/netencode.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'users/Profpatsch/netencode/netencode.rs') diff --git a/users/Profpatsch/netencode/netencode.rs b/users/Profpatsch/netencode/netencode.rs index 249cc33ed1..ab10af307c 100644 --- a/users/Profpatsch/netencode/netencode.rs +++ b/users/Profpatsch/netencode/netencode.rs @@ -26,6 +26,7 @@ pub enum T { Binary(Vec), // Tags // TODO: make into &str + // TODO: rename to Tag Sum(Tag), // TODO: make into &str Record(HashMap), @@ -81,9 +82,10 @@ pub enum U<'a> { // Text Text(&'a str), Binary(&'a [u8]), - // Tags // TODO: the U-recursion we do here means we can’t be breadth-lazy anymore // like we originally planned; maybe we want to go `U<'a>` → `&'a [u8]` again? + // Tags + // TODO: rename to Tag Sum(Tag<&'a str, U<'a>>), Record(HashMap<&'a str, U<'a>>), List(Vec>), @@ -195,7 +197,7 @@ pub fn u_from_stdin_or_die_user_error<'a>(prog_name: &'_ str, stdin_buf: &'a mut let u = match parse::u_u(stdin_buf) { Ok((rest, u)) => match rest { b"" => u, - _ => exec_helpers::die_user_error(prog_name, format!("stdin contained some soup after netencode value: {:?}", rest)) + _ => exec_helpers::die_user_error(prog_name, format!("stdin contained some soup after netencode value: {:?}", String::from_utf8_lossy(rest))) }, Err(err) => exec_helpers::die_user_error(prog_name, format!("unable to parse netencode from stdin: {:?}", err)) }; -- cgit 1.4.1