use std::sync::Arc;
use crate::api::{self, Api};
use crate::cursor::Cursor;
use super::{stream::{GeneralStreamGen, GeneralStreamResult}, UserMeta, Studio, StudioProject, StudioCommentMeta, StudioAction, StudioComment};
use async_trait::async_trait;
#[derive(Clone)] pub struct StudioCurators;
#[async_trait] impl GeneralStreamGen for StudioCurators {
type Data = UserMeta;
type Error = api::Error;
type This = Studio;
async fn gen(&self, cursor: Cursor, this: &Arc<Self::This>, api: &Arc<Api>) -> GeneralStreamResult<Self> {
Ok(UserMeta::vec_new(api.studio_curators(this.id, cursor).await?, api.clone()))
}
}
#[derive(Clone)] pub struct StudioManagers;
#[async_trait] impl GeneralStreamGen for StudioManagers {
type Data = UserMeta;
type Error = api::Error;
type This = Studio;
async fn gen(&self, cursor: Cursor, this: &Arc<Self::This>, api: &Arc<Api>) -> GeneralStreamResult<Self> {
Ok(UserMeta::vec_new(api.studio_managers(this.id, cursor).await?, api.clone()))
}
}
#[derive(Clone)] pub struct StudioProjects;
#[async_trait] impl GeneralStreamGen for StudioProjects {
type Data = StudioProject;
type Error = api::Error;
type This = Studio;
async fn gen(&self, cursor: Cursor, this: &Arc<Self::This>, api: &Arc<Api>) -> GeneralStreamResult<Self> {
Ok(StudioProject::vec_new(api.studio_projects(this.id, cursor).await?, api.clone()))
}
}
#[derive(Clone)] pub struct StudioComments;
#[async_trait] impl GeneralStreamGen for StudioComments {
type Data = StudioCommentMeta;
type Error = api::Error;
type This = Studio;
async fn gen(&self, cursor: Cursor, this: &Arc<Self::This>, api: &Arc<Api>) -> GeneralStreamResult<Self> {
Ok(StudioCommentMeta::vec_new(api.studio_comments(this.id, cursor).await?, this.clone(), api.clone()))
}
}
#[derive(Clone)] pub struct StudioCommentReplies;
#[async_trait] impl GeneralStreamGen for StudioCommentReplies {
type Data = StudioCommentMeta;
type Error = api::Error;
type This = StudioComment;
async fn gen(&self, cursor: Cursor, this: &Arc<Self::This>, api: &Arc<Api>) -> GeneralStreamResult<Self> {
Ok(StudioCommentMeta::vec_new(api.studio_comment_replies(this.at.id, this.id, cursor).await?, this.at.clone(), api.clone()))
}
}
#[derive(Clone)] pub struct StudioActivity;
#[async_trait] impl GeneralStreamGen for StudioActivity {
type Data = StudioAction;
type Error = api::GetStudioActivityError;
type This = Studio;
async fn gen(&self, cursor: Cursor, this: &Arc<Self::This>, api: &Arc<Api>) -> GeneralStreamResult<Self> {
Ok(StudioAction::vec_new(api.studio_activity(this.id, cursor).await?, api.clone()))
}
}