mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-11-30 04:40:47 +01:00
handlers
This commit is contained in:
parent
dfc702f43d
commit
ca61f4ea6a
8 changed files with 531 additions and 11 deletions
42
src/common.rs
Normal file
42
src/common.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
use crate::raw_event::RawSubject;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum Team {
|
||||
Red,
|
||||
Blue,
|
||||
}
|
||||
|
||||
impl FromStr for Team {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"Blue" => Ok(Team::Blue),
|
||||
"Red" => Ok(Team::Red),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Optimized subject id
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum SubjectId {
|
||||
Player(u8),
|
||||
Team(Team),
|
||||
System,
|
||||
World,
|
||||
Console,
|
||||
}
|
||||
|
||||
impl From<&RawSubject<'_>> for SubjectId {
|
||||
fn from(raw: &RawSubject) -> Self {
|
||||
match raw {
|
||||
RawSubject::Player { user_id, .. } => SubjectId::Player(user_id.parse().unwrap()),
|
||||
RawSubject::Team(team) => SubjectId::Team(team.parse().unwrap()),
|
||||
RawSubject::System(_) => SubjectId::System,
|
||||
RawSubject::Console => SubjectId::Console,
|
||||
RawSubject::World => SubjectId::World,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue