pub fn json_encrypt_prop(json: &mut serde_json::Value, prop: &str) -> Result<(), Error> {
    match json {
        serde_json::Value::Object(value) => match value.get(prop) {
            // TODO: Should I prevent double encrypting by failing with String values?
            // Some(serde_json::Value::String(_)) => Err(Error::RequiresJsonObject),

            // Other value types just fine, usually it should be object though
            Some(v) => {
                let json_encrypted = gpg::encrypt(&serde_json::to_string(v)?)?;
                value.insert(prop.into(), serde_json::Value::String(json_encrypted));
                Ok(())
            }
            None => Err(Error::SecretsPropertyMissing),
        },
        _ => Err(Error::RequiresJsonObject),
    }
}
/// GPG encrypt the property value to string
GPG encrypt the property value to string
GPG encrypt the property value to string
pub fn json_encrypt_prop(json: &mut serde_json::Value, prop: &str) -> Result<(), Error> {
    match json {
        serde_json::Value::Object(value) => match value.get(prop) {
            // TODO: Should I prevent double encrypting by failing with String values?
            // Some(serde_json::Value::String(_)) => Err(Error::RequiresJsonObject),
            // Other value types just fine, usually it should be object though
            Some(v) => {
                let json_encrypted = gpg::encrypt(&serde_json::to_string(v)?)?;
                value.insert(prop.into(), serde_json::Value::String(json_encrypted));
                Ok(())
            }
            None => Err(Error::SecretsPropertyMissing),
        },
        _ => Err(Error::RequiresJsonObject),
    }
}
pub fn json_encrypt_prop ( json : & mut serde_json :: Value , prop : & str ) -> Result < ( ) , Error > { match json { serde_json :: Value :: Object ( value ) => match value . get ( prop ) { // TODO: Should I prevent double encrypting by failing with String values? // Some(serde_json::Value::String(_)) => Err(Error::RequiresJsonObject), // Other value types just fine, usually it should be object though Some ( v ) => { let json_encrypted = gpg :: encrypt ( & serde_json :: to_string ( v ) ? ) ? ; value . insert ( prop . into ( ) , serde_json :: Value :: String ( json_encrypted ) ) ; Ok ( ( ) ) } None => Err ( Error :: SecretsPropertyMissing ) , } , _ => Err ( Error :: RequiresJsonObject ) , } }
GPG encrypt the property value to string
GPG encrypt the property value to string
json
&mut serde_json::Value
prop
&str
json
&mut serde_json::Value
prop
&str