File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
//! Extensions of the auto-generated "models" (schema structs).
2
2
3
+ use std:: str:: FromStr ;
4
+
3
5
use serde_json:: json;
4
6
5
- use crate :: models:: MessageIn ;
7
+ use crate :: { api :: Ordering , models:: MessageIn } ;
6
8
7
9
impl MessageIn {
8
10
/// Create a new message with a pre-serialized payload.
@@ -38,3 +40,19 @@ impl MessageIn {
38
40
self
39
41
}
40
42
}
43
+
44
+ #[ derive( Debug , thiserror:: Error ) ]
45
+ #[ error( "invalid value for ordering" ) ]
46
+ pub struct OrderingFromStrError ;
47
+
48
+ impl FromStr for Ordering {
49
+ type Err = OrderingFromStrError ;
50
+
51
+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
52
+ match s {
53
+ "ascending" => Ok ( Self :: Ascending ) ,
54
+ "descending" => Ok ( Self :: Descending ) ,
55
+ _ => Err ( OrderingFromStrError ) ,
56
+ }
57
+ }
58
+ }
You can’t perform that action at this time.
0 commit comments