jake
4 years ago
8 changed files with 175 additions and 135 deletions
-
49src/entity/gateway/entitygateway.rs
-
64src/entity/gateway/inmemory.rs
-
2src/entity/gateway/mod.rs
-
143src/entity/gateway/postgres/postgres.rs
-
14src/login/character.rs
-
2src/login/login.rs
-
33src/ship/items/manager.rs
-
3src/ship/ship.rs
@ -1,80 +1,91 @@ |
|||
use thiserror::Error;
|
|||
|
|||
use crate::entity::account::*;
|
|||
use crate::entity::character::*;
|
|||
use crate::entity::item::*;
|
|||
|
|||
// TODO: all these Options should be Results
|
|||
|
|||
// TODO: better granularity?
|
|||
//#[derive(Error, Debug)]
|
|||
#[derive(Error, Debug)]
|
|||
#[error("")]
|
|||
pub enum GatewayError {
|
|||
Error,
|
|||
PgError(#[from] sqlx::Error)
|
|||
}
|
|||
|
|||
#[async_trait::async_trait]
|
|||
pub trait EntityGateway: Send + Sync + Clone {
|
|||
async fn create_user(&mut self, _user: NewUserAccountEntity) -> Option<UserAccountEntity> {
|
|||
async fn create_user(&mut self, _user: NewUserAccountEntity) -> Result<UserAccountEntity, GatewayError> {
|
|||
unimplemented!()
|
|||
}
|
|||
|
|||
async fn get_user_by_id(&self, _id: UserAccountId) -> Option<UserAccountEntity> {
|
|||
async fn get_user_by_id(&self, _id: UserAccountId) -> Result<UserAccountEntity, GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn get_user_by_name(&self, _username: String) -> Option<UserAccountEntity> {
|
|||
async fn get_user_by_name(&self, _username: String) -> Result<UserAccountEntity, GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn save_user(&mut self, _user: &UserAccountEntity) {
|
|||
async fn save_user(&mut self, _user: &UserAccountEntity) -> Result<(), GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn create_user_settings(&mut self, _settings: NewUserSettingsEntity) -> Option<UserSettingsEntity> {
|
|||
async fn create_user_settings(&mut self, _settings: NewUserSettingsEntity) -> Result<UserSettingsEntity, GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn get_user_settings_by_user(&self, _user: &UserAccountEntity) -> Option<UserSettingsEntity> {
|
|||
async fn get_user_settings_by_user(&self, _user: &UserAccountEntity) -> Result<UserSettingsEntity, GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn save_user_settings(&mut self, _settings: &UserSettingsEntity) {
|
|||
async fn save_user_settings(&mut self, _settings: &UserSettingsEntity) -> Result<(), GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn create_character(&mut self, _char: NewCharacterEntity) -> Option<CharacterEntity> {
|
|||
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(&self, _user: &UserAccountEntity) -> [Option<CharacterEntity>; 4] {
|
|||
async fn get_characters_by_user(&self, _user: &UserAccountEntity) -> Result<[Option<CharacterEntity>; 4], GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn save_character(&mut self, _char: &CharacterEntity) {
|
|||
async fn save_character(&mut self, _char: &CharacterEntity) -> Result<(), GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn get_guild_card_data_by_user(&self, _user: &UserAccountEntity) -> GuildCardDataEntity {
|
|||
async fn get_guild_card_data_by_user(&self, _user: &UserAccountEntity) -> Result<GuildCardDataEntity, GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn create_item(&mut self, _item: NewItemEntity) -> Option<ItemEntity> {
|
|||
async fn create_item(&mut self, _item: NewItemEntity) -> Result<ItemEntity, GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn save_item(&mut self, _item: &ItemEntity) {
|
|||
async fn save_item(&mut self, _item: &ItemEntity) -> Result<(), GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn change_item_location(&mut self, _item_id: &ItemEntityId, _item_location: ItemLocation) {
|
|||
async fn change_item_location(&mut self, _item_id: &ItemEntityId, _item_location: ItemLocation) -> Result<(), GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn feed_mag(&mut self, _mag_item_id: &ItemEntityId, _tool_item_id: &ItemEntityId) {
|
|||
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) {
|
|||
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) {
|
|||
async fn use_mag_cell(&mut self, _mag_item_id: &ItemEntityId, _mag_cell_id: &ItemEntityId) -> Result<(), GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
|
|||
async fn get_items_by_character(&self, _char: &CharacterEntity) -> Vec<ItemEntity> {
|
|||
async fn get_items_by_character(&self, _char: &CharacterEntity) -> Result<Vec<ItemEntity>, GatewayError> {
|
|||
unimplemented!();
|
|||
}
|
|||
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue