diff --git a/src/engines/kv.rs b/src/engines/kv.rs index fbf914d..19afc4d 100644 --- a/src/engines/kv.rs +++ b/src/engines/kv.rs @@ -61,6 +61,7 @@ async fn get_data( Ok(v) => { let version: i64 = v.get("version_number"); let secret_content: HashMap = HashMap::from([ + // TODO: use sqlx to parse the row to a struct, do not do it manually ("secret_data".to_string(), v.get("secret_data")), ("created_time".to_string(), v.get("created_time")), ("deletion_time".to_string(), v.get("deletion_time")), diff --git a/src/engines/kv/logic.rs b/src/engines/kv/logic.rs index d0c8e94..b9cfb96 100644 --- a/src/engines/kv/logic.rs +++ b/src/engines/kv/logic.rs @@ -4,26 +4,33 @@ use super::structs::*; // TODO create default function +#[deprecated(note = "Use Axum functionality with structs instead, also, this should be inlined if it is actually needed")] /// serialize secret to JSON String pub fn serialize_secret_json(secret: &KvSecretReq) -> Result { serde_json::to_string(&secret) } +#[deprecated(note = "Use Axum functionality with structs instead, also, this should be inlined if it is actually needed")] /// deserialize JSON String to secret pub fn deserialize_secret_struct(raw: &String) -> Result { serde_json::from_str(raw) } +#[deprecated(note = "Use Axum functionality with structs instead, also, this should be inlined if it is actually needed")] /// serialize metadata to JSON String pub fn serialize_metadata_json(secret: &SecretMeta) -> Result { serde_json::to_string(&secret) } +#[deprecated(note = "Use Axum functionality with structs instead, also, this should be inlined if it is actually needed")] /// deserialize JSON String to metadata pub fn deserialize_metadata_struct(raw: &String) -> Result { serde_json::from_str(raw) } +#[deprecated(note = "Propably not needed (remove deprecation if actually needed)")] +/// Consider: +/// Instead of patching JSON, we should apply the modified fields directly to the database pub fn patch_metadata( old: &mut SecretMeta, new: &SecretMeta, @@ -34,7 +41,11 @@ pub fn patch_metadata( serde_json::from_value(patch) } +#[deprecated(note = "DO NOT USE: Use Axum extractors to structs instead")] +#[allow(unreachable_code, unused_variables)] +/// See [JSON extractor documentation](https://docs.rs/axum/latest/axum/struct.Json.html#extractor-example) pub fn body_to_json(body: String) -> Value { + todo!("REMOVE: Use Axum extractors to structs instead"); match serde_json::from_str::(body.as_str()) { Ok(val) => val, Err(e) => {