1
0
mirror of https://github.com/pcvolkmer/arsnova-client.git synced 2025-07-01 14:32:54 +00:00

feat: apply typestate pattern to client

This prevents using the client without using guest login and without token.
This commit is contained in:
2023-12-20 14:36:45 +01:00
parent b116457796
commit 9cdd68abed
3 changed files with 30 additions and 11 deletions

View File

@ -55,14 +55,12 @@ pub struct Cli {
async fn main() -> Result<(), ()> {
let cli = Cli::parse();
let mut client = match Client::new(&cli.url) {
let client = match Client::new(&cli.url) {
Ok(client) => client,
Err(_) => return Err(()),
};
if client.guest_login().await.is_err() {
return Err(());
}
let client = client.guest_login().await.map_err(|_| ())?;
let (tx, rx) = channel::<Feedback>(10);