use std::fmt::Display; use async_trait::async_trait; use gamenight_api_client_rs::models::UserId; use uuid::Uuid; use super::{Flow, FlowOutcome, FlowResult, GamenightState}; #[derive(Clone)] pub struct Join { gamenight_id: Uuid } impl Join { pub fn new(gamenight_id: Uuid) -> Self { Self { gamenight_id } } } #[async_trait] impl<'a> Flow<'a> for Join { async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> { let _ = state.api.post_gamenight_participants(&self.gamenight_id.to_string(), Some(UserId{user_id: state.get_user_id()?.to_string()})).await?; clear_screen::clear(); Ok((FlowOutcome::Successful, state)) } } impl Display for Join { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "Join") } }