refactor: update ffxiv_types

This commit is contained in:
Kyle Clemens 2018-09-02 16:01:22 -04:00
parent 6820aff913
commit ab89c33038
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
3 changed files with 8 additions and 41 deletions

View File

@ -23,6 +23,6 @@ version = "0.4"
features = ["serde"]
[dependencies.ffxiv_types]
version = "0.2"
version = "0.3"
default-features = false
features = ["worlds", "with_serde"]
features = ["worlds", "races", "clans", "guardians", "with_serde"]

View File

@ -1,14 +1,13 @@
use crate::models::character::{
Character,
CityState,
Clan,
Gender,
GrandCompany,
GrandCompanyInfo,
Guardian,
Race,
};
use ffxiv_types::{Race, Clan, Guardian};
use scraper::Html;
use std::str::FromStr;
@ -41,18 +40,18 @@ pub fn parse(id: u64, html: &str) -> Option<Character> {
let mut rcg = html.select(&*PROFILE_RACE_CLAN_GENDER).next()?.text();
let race = Race::parse(rcg.next()?)?;
let race = Race::from_str(rcg.next()?).ok()?;
let mut clan_gender_str = rcg.next()?.split(" / ");
let clan = Clan::parse(clan_gender_str.next()?)?;
let clan = Clan::from_str(clan_gender_str.next()?).ok()?;
let gender = Gender::parse(clan_gender_str.next()?)?;
let name_day = html.select(&*PROFILE_NAME_DAY).next()?.text().collect();
let guardian_str: String = html.select(&*PROFILE_GUARDIAN).next()?.text().collect();
let guardian = Guardian::parse(&guardian_str)?;
let guardian = Guardian::from_str(guardian_str.split(",").next()?).ok()?;
let city_state_str: String = html.select(&*PROFILE_CITY_STATE).next()?.text().collect();
let city_state = CityState::parse(&city_state_str)?;

View File

@ -1,4 +1,4 @@
use ffxiv_types::World;
use ffxiv_types::{World, Race, Clan, Guardian};
#[derive(Debug, Serialize)]
pub struct Character {
@ -32,44 +32,12 @@ ffxiv_enum!(Gender {
Female => "",
});
ffxiv_enum!(Race {
AuRa => "Au Ra",
Elezen => "Elezen",
Hyur => "Hyur",
Lalafell => "Lalafell",
Miqote => "Miqo'te",
Roegadyn => "Roegadyn",
});
ffxiv_enum!(Clan {
Raen => "Raen",
Xaela => "Xaela",
Duskwight => "Duskwight",
Wildwood => "Wildwood",
Highlander => "Highlander",
Midlander => "Midlander",
Dunesfolk => "Dunesfolk",
Plainsfolk => "Plainsfolk",
SeekerOfTheMoon => "Seeker of the Moon",
SeekerOfTheSun => "Seeker of the Sun",
Hellsguard => "Hellsguard",
SeaWolf => "Sea Wolf",
});
ffxiv_enum!(GrandCompany {
Flames => "Immortal Flames",
Maelstrom => "Maelstrom",
TwinAdders => "Order of the Twin Adder",
});
ffxiv_enum!(Guardian {
Althyk => "Althyk, the Keeper",
Halone => "Halone, the Fury",
Menphina => "Menphina, the Lover",
Oschon => "Oschon, the Wanderer",
Rhalgr => "Rhalgr, the Destroyer",
});
ffxiv_enum!(CityState {
Gridania => "Gridania",
LimsaLominsa => "Limsa Lominsa",