165 lines
5.6 KiB
Rust
165 lines
5.6 KiB
Rust
use thiserror::Error;
|
|
use futures::future::{Future, BoxFuture};
|
|
|
|
use crate::entity::account::*;
|
|
use crate::entity::character::*;
|
|
use crate::entity::item::*;
|
|
|
|
|
|
// TODO: better granularity?
|
|
//#[derive(Error, Debug)]
|
|
#[derive(Error, Debug)]
|
|
pub enum GatewayError {
|
|
#[error("unknown error")]
|
|
Error,
|
|
#[error("postgres error {0}")]
|
|
PgError(#[from] sqlx::Error)
|
|
}
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
pub trait EntityGateway: Send + Sync {
|
|
type Transaction<'t>: EntityGatewayTransaction + Clone where Self: 't;
|
|
|
|
fn with_transaction<'a, F, Fut, R>(&'a mut self, _func: F) -> BoxFuture<'a, Result<R, anyhow::Error>>
|
|
where
|
|
Fut: Future<Output = Result<(Self::Transaction<'a>, R), anyhow::Error>> + Send + 'a,
|
|
F: FnOnce(Self::Transaction<'a>) -> Fut + Send + 'a,
|
|
R: Send,
|
|
Self: Sized
|
|
{
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn create_user(&mut self, _user: NewUserAccountEntity) -> Result<UserAccountEntity, GatewayError> {
|
|
unimplemented!()
|
|
}
|
|
|
|
async fn get_user_by_id(&mut self, _id: UserAccountId) -> Result<UserAccountEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_user_by_name(&mut self, _username: String) -> Result<UserAccountEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn save_user(&mut self, _user: &UserAccountEntity) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn create_user_settings(&mut self, _settings: NewUserSettingsEntity) -> Result<UserSettingsEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_user_settings_by_user(&mut self, _user: &UserAccountEntity) -> Result<UserSettingsEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn save_user_settings(&mut self, _settings: &UserSettingsEntity) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn create_character(&mut self, _char: NewCharacterEntity) -> Result<CharacterEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
// TODO: just make this a vec sorted by slot order?
|
|
async fn get_characters_by_user(&mut self, _user: &UserAccountEntity) -> Result<[Option<CharacterEntity>; 4], GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn save_character(&mut self, _char: &CharacterEntity) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_guild_card_data_by_user(&mut self, _user: &UserAccountEntity) -> Result<GuildCardDataEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn create_item(&mut self, _item: NewItemEntity) -> Result<ItemEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn add_item_note(&mut self, _item_id: &ItemEntityId, _item_note: ItemNote) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn feed_mag(&mut self, _mag_item_id: &ItemEntityId, _tool_item_id: &ItemEntityId) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn change_mag_owner(&mut self, _mag_item_id: &ItemEntityId, _character: &CharacterEntity) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn use_mag_cell(&mut self, _mag_item_id: &ItemEntityId, _mag_cell_id: &ItemEntityId) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn add_weapon_modifier(&mut self, _item_id: &ItemEntityId, _modifier: &weapon::WeaponModifier) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_character_inventory(&mut self, _char_id: &CharacterEntityId) -> Result<InventoryEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_character_bank(&mut self, _char_id: &CharacterEntityId, _bank_identifier: &BankIdentifier) -> Result<BankEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn set_character_inventory(&mut self, _char_id: &CharacterEntityId, _inventory: &InventoryEntity) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn set_character_bank(&mut self, _char_id: &CharacterEntityId, _bank: &BankEntity, _bank_identifier: &BankIdentifier) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_character_equips(&mut self, _char_id: &CharacterEntityId) -> Result<EquippedEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn set_character_equips(&mut self, _char_id: &CharacterEntityId, _equips: &EquippedEntity) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_character_meseta(&mut self, _char_id: &CharacterEntityId) -> Result<Meseta, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn set_character_meseta(&mut self, _char_id: &CharacterEntityId, _amount: Meseta) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn get_bank_meseta(&mut self, _char_id: &CharacterEntityId, _bank_identifier: &BankIdentifier) -> Result<Meseta, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn set_bank_meseta(&mut self, _char_id: &CharacterEntityId, _bank_identifier: &BankIdentifier, _amount: Meseta) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn create_trade(&mut self, _char_id1: &CharacterEntityId, _char_id2: &CharacterEntityId) -> Result<TradeEntity, GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
|
|
async fn set_character_playtime(&mut self, _char_id: &CharacterEntityId, _playtime: u32) -> Result<(), GatewayError> {
|
|
unimplemented!();
|
|
}
|
|
}
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
pub trait EntityGatewayTransaction: Send + Sync + Sized {
|
|
type ParentGateway: EntityGateway + Clone;
|
|
|
|
fn gateway(&mut self) -> &mut Self::ParentGateway {
|
|
unimplemented!()
|
|
}
|
|
|
|
async fn commit(self) -> Result<(), GatewayError> {
|
|
unimplemented!()
|
|
}
|
|
}
|