Skip to content

Commit 097a0eb

Browse files
committed
custom list serialization impl because i think i need one
1 parent 13e4e73 commit 097a0eb

File tree

2 files changed

+11
-5
lines changed
  • pointercrate-demonlist-api/src
  • pointercrate-demonlist/src

2 files changed

+11
-5
lines changed

pointercrate-demonlist-api/src/list.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ impl<'a> FromParam<'a> for ClientList {
1616
type Error = CoreError;
1717

1818
fn from_param(param: &'a str) -> Result<Self, Self::Error> {
19-
match List::from_str(param) {
20-
Ok(list) => Ok(ClientList(list)),
21-
Err(err) => Err(err),
22-
}
19+
Ok(ClientList(List::from_str(param)?))
2320
}
2421
}
2522

pointercrate-demonlist/src/list.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::str::FromStr;
33
use pointercrate_core::error::CoreError;
44
use serde::{Deserialize, Serialize};
55

6-
#[derive(Debug, PartialEq, Eq, Serialize, Clone, Copy)]
6+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
77
pub enum List {
88
Demonlist, // only consists of rated demons (Demonlist)
99
RatedPlus, // consists of ALL demons (Rated+ List)
@@ -49,6 +49,15 @@ impl ToString for List {
4949
}
5050
}
5151

52+
impl Serialize for List {
53+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
54+
where
55+
S: serde::Serializer,
56+
{
57+
serializer.serialize_str(self.as_str())
58+
}
59+
}
60+
5261
impl<'de> Deserialize<'de> for List {
5362
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
5463
where

0 commit comments

Comments
 (0)