diff options
author | Profpatsch <mail@profpatsch.de> | 2021-01-29T14·54+0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2021-01-31T11·10+0000 |
commit | cf3aab3b787acd05d1f15bf6e600c20f3196cb23 (patch) | |
tree | fcec7565c625ded0e17ef026fc9aeb435e40749a /users/Profpatsch/netencode/default.nix | |
parent | 38772432118cfc6818f9fac1f6d1e424c075e527 (diff) |
feat(users/Profpatsch/netencode): add record-splice-env r/2173
Splice a netencode record from stdin into the environment. Change-Id: I7eac19e18164e070e4463ee431d9b0e955857b9c Reviewed-on: https://cl.tvl.fyi/c/depot/+/2454 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to '')
-rw-r--r-- | users/Profpatsch/netencode/default.nix | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/users/Profpatsch/netencode/default.nix b/users/Profpatsch/netencode/default.nix index f5f038579be6..99cffc75b618 100644 --- a/users/Profpatsch/netencode/default.nix +++ b/users/Profpatsch/netencode/default.nix @@ -89,11 +89,36 @@ let } (builtins.readFile ./netencode-mustache.rs); + record-splice-env = imports.writers.rustSimple { + name = "record-splice-env"; + dependencies = [ + netencode-rs + depot.users.Profpatsch.execline.exec-helpers + ]; + } '' + extern crate netencode; + extern crate exec_helpers; + use netencode::dec::{Record, ScalarAsBytes, Decoder, DecodeError}; + fn main() { + let t = netencode::t_from_stdin_or_panic("record-splice-env"); + match Record::<ScalarAsBytes>::dec(t) { + Ok(map) => { + exec_helpers::exec_into_args( + "record-splice-env", + map.iter().map(|(k,v)| (k.as_bytes(), &v[..]) + ); + }, + Err(DecodeError(err)) => panic!("{}", err), + } + } + ''; + in { inherit netencode-rs netencode-rs-tests netencode-mustache + record-splice-env gen ; } |