pub mod make_link;
pub mod post;
use serde::Deserialize;
#[derive(Debug, PartialEq)]
pub struct Link {
url: String,
}
impl Link {
pub fn init(url: String) -> Self {
Self { url }
}
fn url(&self) -> &str {
&self.url
}
pub async fn search<T>(&self) -> Result<T, reqwest::Error>
where
for<'de> T: Deserialize<'de>,
{
let posts: T = reqwest::get(self.url()).await?.json().await?;
Ok(posts)
}
}