parse_book_source/explore/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pub mod explore_item;
use std::ops::Deref;

use crate::{ParseError, Result};
pub use explore_item::*;

#[derive(Debug, Clone)]
pub struct Explores {
    pub explore_list: Vec<ExploreItem>,
}

impl Explores {
    pub fn from_json(json: &str) -> Result<Self> {
        let explore_list = serde_json::from_str(json)?;
        Ok(Self { explore_list })
    }
}

impl TryFrom<&str> for Explores {
    type Error = ParseError;
    fn try_from(value: &str) -> Result<Self> {
        Self::from_json(value)
    }
}

impl Deref for Explores {
    type Target = Vec<ExploreItem>;
    fn deref(&self) -> &Self::Target {
        &self.explore_list
    }
}