1use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7use std::path::PathBuf;
8use thiserror::Error;
9
10#[derive(Error, Debug)]
11pub enum WikiError {
12 #[error("HTTP error: {0}")]
13 Http(#[from] reqwest::Error),
14
15 #[error("Parse error: {0}")]
16 Parse(String),
17
18 #[error("Cache error: {0}")]
19 Cache(String),
20
21 #[error("Not found: {0}")]
22 NotFound(String),
23}
24
25#[allow(dead_code)]
27pub struct WikiClient {
28 client: reqwest::Client,
29 cache_dir: PathBuf,
30 base_url: String,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct SkillGem {
36 pub name: String,
37 pub tags: Vec<String>,
38 pub description: String,
39 pub base_damage: Option<DamageInfo>,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct DamageInfo {
44 pub min: f64,
45 pub max: f64,
46 pub damage_type: String,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct UniqueItem {
52 pub name: String,
53 pub base_type: String,
54 pub modifiers: Vec<String>,
55 pub requirements: HashMap<String, i32>,
56}
57
58impl WikiClient {
59 pub fn new(cache_dir: PathBuf) -> Self {
61 Self {
62 client: reqwest::Client::new(),
63 cache_dir,
64 base_url: "https://www.poewiki.net/wiki/".to_owned(),
65 }
66 }
67
68 pub async fn get_skill(&self, name: &str) -> Result<SkillGem, WikiError> {
70 tracing::debug!("Fetching skill: {}", name);
75
76 Err(WikiError::NotFound(name.to_owned()))
78 }
79
80 pub async fn get_unique(&self, name: &str) -> Result<UniqueItem, WikiError> {
82 tracing::debug!("Fetching unique: {}", name);
84 Err(WikiError::NotFound(name.to_owned()))
85 }
86
87 pub async fn search(&self, query: &str) -> Result<Vec<String>, WikiError> {
89 tracing::debug!("Searching wiki for: {}", query);
91 Ok(Vec::new())
92 }
93
94 pub fn clear_cache(&self) -> Result<(), WikiError> {
96 Ok(())
98 }
99}