Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Sep 4, 2024
1 parent c6bc78e commit 9ea540a
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::Id;

pub mod data;
pub mod db_entry;
pub mod mapped;
pub mod pipeline;
pub mod provider;

Expand Down
51 changes: 51 additions & 0 deletions src/comment/provider.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::comment::data::CommentData;
use crate::comment::mapped::MappedCommentData;
use crate::comment::pipeline::del::CommentDelPipeline;
use crate::comment::pipeline::get::CommentGetPipeline;
use crate::comment::pipeline::ini::CommentIniPipeline;
use crate::comment::pipeline::set::CommentSetPipeline;
use crate::Id;

#[async_trait]
pub trait CommentProvider {
async fn get_comment(&self, id: Id) -> Result<MappedCommentData>;
async fn ini_comment(&self, data: CommentData) -> Result<Id>;
async fn del_comment(&self, id: Id) -> Result<()>;
}

pub struct DefaultCommentProvider {
ini: Box<dyn CommentIniPipeline>,
get: Box<dyn CommentGetPipeline>,
set: Box<dyn CommentSetPipeline>,
del: Box<dyn CommentDelPipeline>
}

impl DefaultCommentProvider {
pub fn new(
ini: Box<dyn CommentIniPipeline>,
get: Box<dyn CommentGetPipeline>,
set: Box<dyn CommentSetPipeline>,
del: Box<dyn CommentDelPipeline>
) -> Self {
DefaultCommentProvider { ini, get, set, del }
}
}

#[async_trait]
impl CommentProvider for DefaultCommentProvider {
async fn get_comment(&self, id: Id) -> Result<MappedCommentData> {
//self.get.get_data(id).await
todo!()
}

async fn ini_comment(&self, data: CommentData) -> Result<Id> {
self.ini.call(data).await
}

async fn del_comment(&self, id: Id) -> Result<()> {
self.del.call(id).await
}
}
1 change: 1 addition & 0 deletions src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::Id;

pub mod data;
pub mod db_entry;
pub mod mapped;
pub mod pipeline;
pub mod provider;

Expand Down
49 changes: 49 additions & 0 deletions src/post/provider.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::post::data::PostData;
use crate::post::mapped::MappedPostData;
use crate::post::pipeline::del::PostDelPipeline;
use crate::post::pipeline::get::PostGetPipeline;
use crate::post::pipeline::ini::PostIniPipeline;
use crate::post::pipeline::set::PostSetPipeline;
use crate::Id;

#[async_trait]
pub trait PostProvider {
async fn get_post(&self, id: Id) -> Result<MappedPostData>;
async fn ini_post(&self, data: PostData) -> Result<Id>;
async fn del_post(&self, id: Id) -> Result<()>;
}

pub struct DefaultPostProvider {
ini: Box<dyn PostIniPipeline>,
get: Box<dyn PostGetPipeline>,
set: Box<dyn PostSetPipeline>,
del: Box<dyn PostDelPipeline>
}

impl DefaultPostProvider {
pub fn new(
ini: Box<dyn PostIniPipeline>,
get: Box<dyn PostGetPipeline>,
set: Box<dyn PostSetPipeline>,
del: Box<dyn PostDelPipeline>
) -> Self {
DefaultPostProvider { ini, get, set, del }
}
}

#[async_trait]
impl PostProvider for DefaultPostProvider {
async fn get_post(&self, id: Id) -> Result<MappedPostData> {
//self.get.get_data(id).await
todo!()
}

async fn ini_post(&self, data: PostData) -> Result<Id> {
self.ini.call(data).await
}

async fn del_post(&self, id: Id) -> Result<()> { self.del.call(id).await }
}
1 change: 1 addition & 0 deletions src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::Id;

pub mod data;
pub mod db_entry;
pub mod mapped;
pub mod pipeline;
pub mod provider;

Expand Down
49 changes: 49 additions & 0 deletions src/user/provider.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::user::data::UserData;
use crate::user::mapped::MappedUserData;
use crate::user::pipeline::del::UserDelPipeline;
use crate::user::pipeline::get::UserGetPipeline;
use crate::user::pipeline::ini::UserIniPipeline;
use crate::user::pipeline::set::UserSetPipeline;
use crate::Id;

#[async_trait]
pub trait UserProvider {
async fn get_user(&self, id: Id) -> Result<MappedUserData>;
async fn ini_user(&self, data: UserData) -> Result<Id>;
async fn del_user(&self, id: Id) -> Result<()>;
}

pub struct DefaultUserProvider {
ini: Box<dyn UserIniPipeline>,
get: Box<dyn UserGetPipeline>,
set: Box<dyn UserSetPipeline>,
del: Box<dyn UserDelPipeline>
}

impl DefaultUserProvider {
pub fn new(
ini: Box<dyn UserIniPipeline>,
get: Box<dyn UserGetPipeline>,
set: Box<dyn UserSetPipeline>,
del: Box<dyn UserDelPipeline>
) -> Self {
DefaultUserProvider { ini, get, set, del }
}
}

#[async_trait]
impl UserProvider for DefaultUserProvider {
async fn get_user(&self, id: Id) -> Result<MappedUserData> {
//self.get.get_data(id).await
todo!()
}

async fn ini_user(&self, data: UserData) -> Result<Id> {
self.ini.call(data).await
}

async fn del_user(&self, id: Id) -> Result<()> { self.del.call(id).await }
}

0 comments on commit 9ea540a

Please sign in to comment.