From 972388a01903b693795004f7720f43df8231fa46 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Fri, 12 Jul 2019 02:55:49 -0700 Subject: [PATCH] Document error conditions for `redact`. --- src/functions.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/functions.rs b/src/functions.rs index 7390a566..b0279309 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -706,6 +706,16 @@ fn canonical_json_with_fields_to_remove(value: &Value, fields: &[&str]) -> Resul /// # Parameters /// /// * value: A JSON object to redact. +/// +/// # Errors +/// +/// Returns an error if: +/// +/// * `value` is not a JSON object. +/// * `value` contains a field called `content` that is not a JSON object. +/// * `value` contains a field called `hashes` that is not a JSON object. +/// * `value` contains a field called `signatures` that is not a JSON object. +/// * `value` is missing the `type` field or the field is not a JSON string. pub fn redact(value: &Value) -> Result { if !value.is_object() { return Err(Error::new("JSON value must be a JSON object"));