27 lines
470 B
Gleam
27 lines
470 B
Gleam
pub type ScoreUpdateType {
|
|
Add
|
|
Subtract
|
|
Reset
|
|
}
|
|
|
|
pub type Error {
|
|
InvalidUpdateType
|
|
}
|
|
|
|
pub fn serialize(score_update: ScoreUpdateType) -> String {
|
|
case score_update {
|
|
Add -> "Add"
|
|
Subtract -> "Subtract"
|
|
Reset -> "Reset"
|
|
}
|
|
}
|
|
|
|
pub fn deseralize(score_update_string) -> Result(ScoreUpdateType, Error) {
|
|
case score_update_string {
|
|
"Add" -> Ok(Add)
|
|
"Subtract" -> Ok(Subtract)
|
|
"Reset" -> Ok(Reset)
|
|
_ -> Error(InvalidUpdateType)
|
|
}
|
|
}
|