use async_trait::async_trait;
use serde::de::DeserializeOwned;
use crate::{
client::RustemonClient,
error::Error,
model::resource::{ApiResource, NamedApiResource},
};
#[async_trait]
pub trait Follow<T>
where
T: DeserializeOwned + Send + Sync,
{
async fn follow(&self, rustemon_client: &RustemonClient) -> Result<T, Error>;
}
#[async_trait]
impl<T> Follow<T> for NamedApiResource<T>
where
T: DeserializeOwned + Send + Sync,
{
async fn follow(&self, rustemon_client: &RustemonClient) -> Result<T, Error> {
rustemon_client.get_by_url(&self.url).await
}
}
#[async_trait]
impl<T> Follow<T> for ApiResource<T>
where
T: DeserializeOwned + Send + Sync,
{
async fn follow(&self, rustemon_client: &RustemonClient) -> Result<T, Error> {
rustemon_client.get_by_url(&self.url).await
}
}