From 61e24020450f1d06082b3ff70d3f130844dcb648 Mon Sep 17 00:00:00 2001 From: soruh Date: Sat, 11 Dec 2021 15:59:42 +0100 Subject: [PATCH] deprecate using SerdeValue, SerdeMap and serde_to_value as they are just wrapper around serde_json::{Value, Map, to_value}. Instead expose the serde_json and serde crates used. --- src/lib.rs | 19 ++++++++++++++++++- src/test/body_send.rs | 6 +++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 436fa42..786729f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -398,8 +398,25 @@ pub use crate::stream::TlsConnector; // re-export #[cfg(feature = "cookies")] pub use cookie::Cookie; + #[cfg(feature = "json")] -pub use serde_json::{to_value as serde_to_value, Map as SerdeMap, Value as SerdeValue}; +pub use {serde, serde_json}; + +#[cfg(feature = "json")] +#[deprecated(note = "use ureq::serde_json::Map instead")] +pub type SerdeMap = serde_json::Map; + +#[cfg(feature = "json")] +#[deprecated(note = "use ureq::serde_json::Value instead")] +pub type SerdeValue = serde_json::Value; + +#[cfg(feature = "json")] +#[deprecated(note = "use ureq::serde_json::to_value instead")] +pub fn serde_to_value( + value: T, +) -> std::result::Result { + serde_json::to_value(value) +} use once_cell::sync::Lazy; use std::sync::atomic::{AtomicBool, Ordering}; diff --git a/src/test/body_send.rs b/src/test/body_send.rs index d64fac6..12f23e4 100644 --- a/src/test/body_send.rs +++ b/src/test/body_send.rs @@ -35,7 +35,7 @@ fn content_length_on_json() { test::set_handler("/content_length_on_json", |_unit| { test::make_response(200, "OK", vec![], vec![]) }); - let mut json = SerdeMap::new(); + let mut json = serde_json::Map::new(); json.insert( "Hello".to_string(), serde_json::Value::String("World!!!".to_string()), @@ -87,7 +87,7 @@ fn content_type_on_json() { test::set_handler("/content_type_on_json", |_unit| { test::make_response(200, "OK", vec![], vec![]) }); - let mut json = SerdeMap::new(); + let mut json = serde_json::Map::new(); json.insert( "Hello".to_string(), serde_json::Value::String("World!!!".to_string()), @@ -106,7 +106,7 @@ fn content_type_not_overriden_on_json() { test::set_handler("/content_type_not_overriden_on_json", |_unit| { test::make_response(200, "OK", vec![], vec![]) }); - let mut json = SerdeMap::new(); + let mut json = serde_json::Map::new(); json.insert( "Hello".to_string(), serde_json::Value::String("World!!!".to_string()),