#[cfg(feature = "market_cache")]
pub(crate) mod cache;
mod client;
pub mod error;
pub(crate) mod models;
#[cfg(feature = "market_cache")]
pub use cache::{
SlugContext,
Slugs,
};
pub use client::Client;
use derive_more::{
AsRef,
Display,
Into,
};
pub use error::{
Error,
Result,
};
use heck::ToSnakeCase;
pub use models::{
Queryable,
ResponseBase,
activity::{
Activity,
ActivityType,
},
i18n::{
I18N,
Language,
},
item::{
Item,
ItemI18N,
},
item_short::{
ItemShort,
ItemShortI18N,
},
lich_ephemera::LichEphemeraI18N,
lich_quirk::LichQuirkI18N,
lich_weapon::LichWeaponI18N,
location::LocationI18N,
mission::MissionI18N,
npc::NpcI18N,
order::{
Order,
OrderType,
},
riven::RivenI18N,
riven_attribute::{
RivenAttributeI18N,
Unit,
},
riven_group::RivenGroup,
riven_type::RivenType,
set_items::SetItems,
sister_ephemera::SisterEphemeraI18N,
sister_quirk::SisterQuirkI18N,
sister_weapon::SisterWeaponI18N,
top_orders::TopOrders,
top_orders_query_params::TopOrdersQueryParams,
user_short::{
Status,
UserShort,
},
versions::{
VersionApps,
VersionCollections,
},
};
pub mod queryable {
pub use super::models::{
lich_ephemera::LichEphemera,
lich_quirk::LichQuirk,
lich_weapon::LichWeapon,
location::Location,
mission::Mission,
npc::Npc,
order_with_user::OrderWithUser,
riven::Riven,
riven_attribute::RivenAttribute,
sister_ephemera::SisterEphemera,
sister_quirk::SisterQuirk,
sister_weapon::SisterWeapon,
versions::Versions,
};
}
pub const BASE_URL: &str = "https://api.warframe.market/v2";
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Display, Into, AsRef)]
#[as_ref(str, String)]
pub struct Slug(String);
impl Slug {
#[must_use]
pub fn new(input: &str) -> Self {
Self(input.to_snake_case())
}
#[must_use]
pub fn new_unchecked(input: &str) -> Self {
Self(input.to_string())
}
}
impl From<String> for Slug {
fn from(value: String) -> Self {
Self::new(&value)
}
}
impl From<&str> for Slug {
fn from(value: &str) -> Self {
Self::new(value)
}
}
impl PartialEq<String> for Slug {
fn eq(&self, other: &String) -> bool {
&self.0 == other
}
}
impl PartialEq<str> for Slug {
fn eq(&self, other: &str) -> bool {
self.0 == other
}
}
impl PartialEq<&str> for Slug {
fn eq(&self, other: &&str) -> bool {
self.0 == *other
}
}
#[cfg(test)]
mod test {
use super::Slug;
#[test]
fn test_slug() {
assert_eq!(Slug::new("Acceltra Prime Set"), "acceltra_prime_set");
assert_eq!(Slug::new("Mirage Prime Set"), "mirage_prime_set");
assert_eq!(Slug::new("Riot-848 Barrel"), "riot_848_barrel");
}
}