forked from Roflin/gamenight
Implements leaving on the client side
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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.configuration, Some(GamenightId{gamenight_id: self.gamenight_id.to_string()})).await?;
|
||||
Ok((FlowOutcome::Successful, state))
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Leave {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "Leave")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user