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