My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/games/rstnode/rst-core/src/net/parser.rs

17 lines
529 B

use crate::{
error::Error,
wire::{Request, Response},
GameIf,
};
use std::sync::Arc;
/// Parse a request and call a game interface function for it
pub async fn request(req: Request, game: Arc<impl GameIf>) -> Response {
use Request::*;
match req {
Register(name, pw) => super::register(game.register(name, pw).await),
Login(name, pw_hash) => super::login(game.login(name, pw_hash).await),
Logout(user) => super::logout(game.logout(user).await),
_ => super::invalid(),
}
}