2022-10-17 10:46:51 +00:00
|
|
|
//! Implements [`FromStr`] for parser structs.
|
|
|
|
|
|
|
|
use std::str::FromStr;
|
|
|
|
|
2023-06-09 19:03:38 +00:00
|
|
|
use {duplicate::duplicate_item, scraper::Html};
|
2022-10-17 10:46:51 +00:00
|
|
|
|
2023-06-21 09:59:38 +00:00
|
|
|
use crate::{Group, GroupList, ParseError, Topic};
|
2022-10-17 10:46:51 +00:00
|
|
|
|
|
|
|
#[duplicate_item(
|
|
|
|
_Struct;
|
|
|
|
[Group];
|
|
|
|
[GroupList];
|
2023-06-21 09:59:38 +00:00
|
|
|
[Topic];
|
2022-10-17 10:46:51 +00:00
|
|
|
)]
|
|
|
|
impl FromStr for _Struct {
|
2023-06-09 19:03:38 +00:00
|
|
|
type Err = ParseError;
|
2022-10-17 10:46:51 +00:00
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
let html = Html::parse_document(s);
|
2022-10-17 10:47:35 +00:00
|
|
|
Self::from_html(&html)
|
2022-10-17 10:46:51 +00:00
|
|
|
}
|
|
|
|
}
|