Merge pull request #6 from pxp9/main
Serde for CookieStoreMutex and CookieStoreRwlock
This commit is contained in:
commit
7c7ca659e5
2 changed files with 9 additions and 0 deletions
|
@ -16,11 +16,16 @@ categories = ["web-programming::http-client", "web-programming"] # https://crat
|
|||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[features]
|
||||
serde = ["dep:serde" , "dep:serde_derive"]
|
||||
|
||||
[dependencies]
|
||||
bytes = "1.0.1"
|
||||
cookie_store = "^0.20"
|
||||
reqwest = { version = "^0.11", default-features = false, features = ["cookies"] }
|
||||
url = "2.2.2"
|
||||
serde = {version = "1.0.147", optional = true}
|
||||
serde_derive = {version = "1.0.147" , optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio-test = "0.4.1"
|
||||
|
|
|
@ -87,6 +87,8 @@ use std::{
|
|||
use bytes::Bytes;
|
||||
pub use cookie_store::{CookieStore, RawCookie, RawCookieParseError};
|
||||
use reqwest::header::HeaderValue;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use url;
|
||||
|
||||
fn set_cookies(
|
||||
|
@ -121,6 +123,7 @@ fn cookies(cookie_store: &CookieStore, url: &url::Url) -> Option<HeaderValue> {
|
|||
/// A [`cookie_store::CookieStore`] wrapped internally by a [`std::sync::Mutex`], suitable for use in
|
||||
/// async/concurrent contexts.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct CookieStoreMutex(Mutex<CookieStore>);
|
||||
|
||||
impl Default for CookieStoreMutex {
|
||||
|
@ -164,6 +167,7 @@ impl reqwest::cookie::CookieStore for CookieStoreMutex {
|
|||
/// A [`cookie_store::CookieStore`] wrapped internally by a [`std::sync::RwLock`], suitable for use in
|
||||
/// async/concurrent contexts.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct CookieStoreRwLock(RwLock<CookieStore>);
|
||||
|
||||
impl Default for CookieStoreRwLock {
|
||||
|
|
Loading…
Reference in a new issue