mahjong_service/
common.rs

1use crate::auth::{AuthInfo, GetAuthInfo};
2use async_trait::async_trait;
3use mahjong_core::{GameId, PlayerId};
4use service_contracts::{ServiceGame, ServicePlayer, ServicePlayerGame};
5
6#[async_trait]
7pub trait Storage: Send + Sync {
8    async fn get_auth_info(&self, get_auth_info: GetAuthInfo) -> Result<Option<AuthInfo>, String>;
9    async fn get_game(&self, id: &GameId, use_cache: bool) -> Result<Option<ServiceGame>, String>;
10    async fn get_player_games(
11        &self,
12        player_id: &Option<PlayerId>,
13    ) -> Result<Vec<ServicePlayerGame>, String>;
14    async fn get_player(&self, id: &PlayerId) -> Result<Option<ServicePlayer>, String>;
15    async fn get_player_total_score(&self, id: &PlayerId) -> Result<i32, String>;
16    async fn save_auth_info(&self, auth_info: &AuthInfo) -> Result<(), String>;
17    async fn save_game(&self, game: &ServiceGame) -> Result<(), String>;
18    async fn save_player(&self, player: &ServicePlayer) -> Result<(), String>;
19    async fn delete_games(&self, ids: &[GameId]) -> Result<(), String>;
20}