refactor: update dependencies

This commit is contained in:
Anna 2020-07-23 14:33:48 -04:00
parent 0933a3cb4b
commit f8b2209123
7 changed files with 8 additions and 49 deletions

View File

@ -18,34 +18,22 @@ logic = [
with_serde = [
"serde",
"serde_derive",
"url_serde",
"ffxiv_types/with_serde",
"chrono/serde",
"url/serde"
]
[dependencies]
cssparser = { version = "0.25", optional = true }
chrono = "0.4"
cssparser = { version = "0.27", optional = true }
failure = { version = "0.1", optional = true }
lazy_static = { version = "1", optional = true }
scraper = { version = "0.10", optional = true }
scraper = { version = "0.12", optional = true }
serde = { version = "1", optional = true }
serde_derive = { version = "1", optional = true }
url = "1"
url_serde = { version = "0.2", optional = true }
url = "2"
# with serde
[target.'cfg(feature = "with_serde")'.dependencies.chrono]
version = "0.4"
features = ["serde"]
[target.'cfg(feature = "with_serde")'.dependencies.ffxiv_types]
version = "1"
default-features = false
features = ["worlds", "races", "clans", "guardians", "with_serde"]
# without serde
[target.'cfg(not(feature = "with_serde"))'.dependencies.chrono]
version = "0.4"
[target.'cfg(not(feature = "with_serde"))'.dependencies.ffxiv_types]
[dependencies.ffxiv_types]
version = "1"
default-features = false
features = ["worlds", "races", "clans", "guardians"]

View File

@ -35,9 +35,7 @@ pub struct Character {
#[cfg_attr(feature = "with_serde", serde(default))]
pub minions: Vec<Minion>,
#[cfg_attr(feature = "with_serde", serde(with = "url_serde"))]
pub face: Url,
#[cfg_attr(feature = "with_serde", serde(with = "url_serde"))]
pub portrait: Url,
}
@ -60,7 +58,6 @@ pub struct JobInfo {
#[cfg_attr(feature = "with_serde", derive(Deserialize, Serialize))]
pub struct Mount {
pub name: String,
#[cfg_attr(feature = "with_serde", serde(with = "url_serde"))]
pub icon: Url,
}
@ -68,7 +65,6 @@ pub struct Mount {
#[cfg_attr(feature = "with_serde", derive(Deserialize, Serialize))]
pub struct Minion {
pub name: String,
#[cfg_attr(feature = "with_serde", serde(with = "url_serde"))]
pub icon: Url,
}

View File

@ -15,7 +15,6 @@ pub struct FreeCompany {
pub name: String,
pub world: World,
pub slogan: String,
#[cfg_attr(feature = "with_serde", serde(with = "crate::util::serde::multi_url"))]
pub crest: Vec<Url>,
pub grand_company: GrandCompany,
pub active_members: u16,

View File

@ -14,6 +14,5 @@ pub struct CharacterSearchItem {
pub grand_company: Option<GrandCompanyInfo>,
#[cfg_attr(feature = "with_serde", serde(with = "crate::util::serde::opt_u64_str"))]
pub free_company_id: Option<u64>,
#[cfg_attr(feature = "with_serde", serde(with = "url_serde"))]
pub face: Url,
}

View File

@ -12,7 +12,6 @@ pub struct FreeCompanySearchItem {
pub id: u64,
pub name: String,
pub world: World,
#[cfg_attr(feature = "with_serde", serde(with = "crate::util::serde::multi_url"))]
pub crest: Vec<Url>,
pub grand_company: GrandCompany,
pub active_members: u16,

View File

@ -1,3 +1,2 @@
pub mod multi_url;
pub mod opt_u64_str;
pub mod u64_str;

View File

@ -1,21 +0,0 @@
use serde::{Deserializer, Deserialize, Serializer, ser::SerializeSeq};
use url::Url;
#[allow(clippy::ptr_arg)]
crate fn serialize<S>(urls: &Vec<Url>, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,
{
let mut seq = serializer.serialize_seq(Some(urls.len()))?;
for url in urls {
seq.serialize_element(&url_serde::Ser::new(url))?;
}
seq.end()
}
crate fn deserialize<'de, D>(deserializer: D) -> Result<Vec<Url>, D::Error>
where D: Deserializer<'de>
{
let urls: Vec<url_serde::De<Url>> = Vec::deserialize(deserializer)?;
Ok(urls.into_iter().map(url_serde::De::into_inner).collect())
}