From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v2 backup 2/4] bakckup::manifest: use tools::json for canonical representation
Date: Fri, 15 Jan 2021 11:06:16 +0100 [thread overview]
Message-ID: <20210115100618.1208-2-w.bumiller@proxmox.com> (raw)
In-Reply-To: <20210115100618.1208-1-w.bumiller@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
no changs since v2
src/backup/manifest.rs | 44 +-----------------------------------------
1 file changed, 1 insertion(+), 43 deletions(-)
diff --git a/src/backup/manifest.rs b/src/backup/manifest.rs
index 8742cb0a..d9a55655 100644
--- a/src/backup/manifest.rs
+++ b/src/backup/manifest.rs
@@ -149,49 +149,7 @@ impl BackupManifest {
// Generate canonical json
fn to_canonical_json(value: &Value) -> Result<Vec<u8>, Error> {
- let mut data = Vec::new();
- Self::write_canonical_json(value, &mut data)?;
- Ok(data)
- }
-
- fn write_canonical_json(value: &Value, output: &mut Vec<u8>) -> Result<(), Error> {
- match value {
- Value::Null => bail!("got unexpected null value"),
- Value::String(_) | Value::Number(_) | Value::Bool(_) => {
- serde_json::to_writer(output, &value)?;
- }
- Value::Array(list) => {
- output.push(b'[');
- let mut iter = list.iter();
- if let Some(item) = iter.next() {
- Self::write_canonical_json(item, output)?;
- for item in iter {
- output.push(b',');
- Self::write_canonical_json(item, output)?;
- }
- }
- output.push(b']');
- }
- Value::Object(map) => {
- output.push(b'{');
- let mut keys: Vec<&str> = map.keys().map(String::as_str).collect();
- keys.sort();
- let mut iter = keys.into_iter();
- if let Some(key) = iter.next() {
- serde_json::to_writer(&mut *output, &key)?;
- output.push(b':');
- Self::write_canonical_json(&map[key], output)?;
- for key in iter {
- output.push(b',');
- serde_json::to_writer(&mut *output, &key)?;
- output.push(b':');
- Self::write_canonical_json(&map[key], output)?;
- }
- }
- output.push(b'}');
- }
- }
- Ok(())
+ crate::tools::json::to_canonical_json(value)
}
/// Compute manifest signature
--
2.20.1
next prev parent reply other threads:[~2021-01-15 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 10:06 [pbs-devel] [PATCH v2 backup 1/4] add tools::json for canonical json generation Wolfgang Bumiller
2021-01-15 10:06 ` Wolfgang Bumiller [this message]
2021-01-15 10:06 ` [pbs-devel] [PATCH v2 backup 3/4] tfa: add webauthn configuration API entry points Wolfgang Bumiller
2021-01-15 10:06 ` [pbs-devel] [PATCH v2 backup 4/4] gui: tfa configuration Wolfgang Bumiller
2021-01-15 15:26 ` [pbs-devel] applied-series: [PATCH v2 backup 1/4] add tools::json for canonical json generation Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210115100618.1208-2-w.bumiller@proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox