mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-11-30 04:40:47 +01:00
handler macro
This commit is contained in:
parent
5be2b0a473
commit
e846fcceae
5 changed files with 91 additions and 56 deletions
|
|
@ -4,12 +4,13 @@ use crate::module::EventHandler;
|
|||
use crate::raw_event::RawEventType;
|
||||
use crate::SubjectMap;
|
||||
use chrono::{DateTime, FixedOffset, NaiveDateTime, TimeZone, Utc};
|
||||
use serde::{Serialize, Serializer};
|
||||
use std::num::ParseIntError;
|
||||
use std::str::{FromStr, ParseBoolError};
|
||||
use steamid_ng::SteamID;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Serialize)]
|
||||
pub enum GameType {
|
||||
Sixes,
|
||||
Highlander,
|
||||
|
|
@ -27,7 +28,7 @@ impl FromStr for GameType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Serialize)]
|
||||
pub enum Location {
|
||||
Europe,
|
||||
NorthAmerica,
|
||||
|
|
@ -45,7 +46,7 @@ impl FromStr for Location {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Default, Serialize)]
|
||||
pub struct LobbyLeader {
|
||||
name: String,
|
||||
steam_id: SteamID,
|
||||
|
|
@ -70,7 +71,7 @@ impl FromStr for LobbyLeader {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Settings {
|
||||
id: u32,
|
||||
leader: LobbyLeader,
|
||||
|
|
@ -127,6 +128,15 @@ pub enum LobbySettingsError {
|
|||
InvalidDate(#[from] chrono::ParseError),
|
||||
}
|
||||
|
||||
impl Serialize for LobbySettingsError {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
format!("{}", self).serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum LobbySettingsHandler {
|
||||
NotAvailable,
|
||||
Active(Settings),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue