@@ -5,7 +5,8 @@ pub enum JumpType {
5
5
DEFAULT , // ARCOMMANDS_ID_JUMPINGSUMO_CLASS_PILOTING = 0,
6
6
}
7
7
8
- #[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
8
+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
9
+ /// u8
9
10
pub enum Class {
10
11
Piloting ( PilotingID ) , // ARCOMMANDS_ID_JUMPINGSUMO_CLASS_PILOTING = 0,
11
12
PilotingState , // ARCOMMANDS_ID_JUMPINGSUMO_CLASS_PILOTINGSTATE = 1,
@@ -40,14 +41,15 @@ pub enum Anim {
40
41
SimpleAnimation = 4 , // ARCOMMANDS_ID_JUMPINGSUMO_ANIMATIONS_CMD_SIMPLEANIMATION = 4,
41
42
}
42
43
43
- #[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
44
+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
45
+ /// u16
44
46
pub enum PilotingID {
45
47
Pilot ( PilotState ) , // ARCOMMANDS_ID_JUMPINGSUMO_PILOTING_CMD_PCMD = 0,
46
48
Posture , // ARCOMMANDS_ID_JUMPINGSUMO_PILOTING_CMD_POSTURE = 1,
47
49
AddCapOffset , // ARCOMMANDS_ID_JUMPINGSUMO_PILOTING_CMD_ADDCAPOFFSET = 2,
48
50
}
49
51
50
- #[ derive( Default , Debug , PartialEq , Eq , Clone , Copy ) ]
52
+ #[ derive( Default , Debug , PartialEq , Eq , Clone ) ]
51
53
pub struct PilotState {
52
54
pub flag : bool ,
53
55
pub speed : i8 ,
@@ -56,31 +58,31 @@ pub struct PilotState {
56
58
57
59
// --------------------- Conversion impls --------------------- //
58
60
59
- impl Into < u8 > for Class {
61
+ impl Into < u8 > for & Class {
60
62
fn into ( self ) -> u8 {
61
63
match self {
62
- Self :: Piloting ( _) => 0 ,
63
- Self :: PilotingState => 1 ,
64
- Self :: Animations ( _) => 2 ,
65
- Self :: AnimationsState => 3 ,
66
- Self :: SettingsState => 5 ,
67
- Self :: MediaRecord => 6 ,
68
- Self :: MediaRecordState => 7 ,
69
- Self :: NetworkSettings => 8 ,
70
- Self :: NetworkSettingsState => 9 ,
71
- Self :: Network => 10 ,
72
- Self :: NetworkState => 11 ,
73
- Self :: AutioSettings => 12 ,
74
- Self :: AudioSettingsState => 13 ,
75
- Self :: Roadplan => 14 ,
76
- Self :: RoadplanState => 15 ,
77
- Self :: SpeedSettings => 16 ,
78
- Self :: SpeedSettingsState => 17 ,
79
- Self :: MediaStreaming => 18 ,
80
- Self :: MediaStreamingState => 19 ,
81
- Self :: MediaRecordEvent => 20 ,
82
- Self :: VideoSettings => 21 ,
83
- Self :: VideoSettingsState => 22 ,
64
+ Class :: Piloting ( _) => 0 ,
65
+ Class :: PilotingState => 1 ,
66
+ Class :: Animations ( _) => 2 ,
67
+ Class :: AnimationsState => 3 ,
68
+ Class :: SettingsState => 5 ,
69
+ Class :: MediaRecord => 6 ,
70
+ Class :: MediaRecordState => 7 ,
71
+ Class :: NetworkSettings => 8 ,
72
+ Class :: NetworkSettingsState => 9 ,
73
+ Class :: Network => 10 ,
74
+ Class :: NetworkState => 11 ,
75
+ Class :: AutioSettings => 12 ,
76
+ Class :: AudioSettingsState => 13 ,
77
+ Class :: Roadplan => 14 ,
78
+ Class :: RoadplanState => 15 ,
79
+ Class :: SpeedSettings => 16 ,
80
+ Class :: SpeedSettingsState => 17 ,
81
+ Class :: MediaStreaming => 18 ,
82
+ Class :: MediaStreamingState => 19 ,
83
+ Class :: MediaRecordEvent => 20 ,
84
+ Class :: VideoSettings => 21 ,
85
+ Class :: VideoSettingsState => 22 ,
84
86
}
85
87
}
86
88
}
@@ -97,12 +99,12 @@ impl Into<u8> for Anim {
97
99
}
98
100
}
99
101
100
- impl Into < u16 > for PilotingID {
102
+ impl Into < u16 > for & PilotingID {
101
103
fn into ( self ) -> u16 {
102
104
match self {
103
- Self :: Pilot ( _) => 0 ,
104
- Self :: Posture => 1 ,
105
- Self :: AddCapOffset => 2 ,
105
+ PilotingID :: Pilot ( _) => 0 ,
106
+ PilotingID :: Posture => 1 ,
107
+ PilotingID :: AddCapOffset => 2 ,
106
108
}
107
109
}
108
110
}
@@ -167,7 +169,7 @@ pub mod scroll_impl {
167
169
fn try_into_ctx ( self , this : & mut [ u8 ] , ctx : Endian ) -> Result < usize , Self :: Error > {
168
170
let mut offset = 0 ;
169
171
170
- this. gwrite_with :: < u8 > ( self . into ( ) , & mut offset, ctx) ?;
172
+ this. gwrite_with :: < u8 > ( ( & self ) . into ( ) , & mut offset, ctx) ?;
171
173
match self {
172
174
Self :: Piloting ( piloting_id) => {
173
175
this. gwrite_with ( piloting_id, & mut offset, ctx) ?;
@@ -214,7 +216,7 @@ pub mod scroll_impl {
214
216
215
217
fn try_into_ctx ( self , this : & mut [ u8 ] , ctx : Endian ) -> Result < usize , Self :: Error > {
216
218
let mut offset = 0 ;
217
- this. gwrite_with :: < u16 > ( self . into ( ) , & mut offset, ctx) ?;
219
+ this. gwrite_with :: < u16 > ( ( & self ) . into ( ) , & mut offset, ctx) ?;
218
220
219
221
match self {
220
222
Self :: Pilot ( state) => {
@@ -315,6 +317,7 @@ pub mod scroll_impl {
315
317
#[ cfg( test) ]
316
318
mod jumping_dumo_tests {
317
319
use super :: * ;
320
+ use std:: borrow:: Borrow ;
318
321
319
322
#[ test]
320
323
fn test_piloting_command ( ) {
@@ -358,8 +361,8 @@ mod jumping_dumo_tests {
358
361
assert_class ( Class :: VideoSettingsState , 22 ) ;
359
362
}
360
363
361
- fn assert_class ( dc : Class , v : u8 ) {
362
- let as_u8: u8 = dc. into ( ) ;
364
+ fn assert_class ( dc : impl Borrow < Class > , v : u8 ) {
365
+ let as_u8: u8 = dc. borrow ( ) . into ( ) ;
363
366
assert_eq ! ( v, as_u8) ;
364
367
}
365
368
@@ -368,8 +371,8 @@ mod jumping_dumo_tests {
368
371
assert_eq ! ( v, as_u8) ;
369
372
}
370
373
371
- fn assert_piloting ( pc : PilotingID , v : u16 ) {
372
- let as_u8: u16 = pc. into ( ) ;
374
+ fn assert_piloting ( pc : impl Borrow < PilotingID > , v : u16 ) {
375
+ let as_u8: u16 = pc. borrow ( ) . into ( ) ;
373
376
assert_eq ! ( v, as_u8) ;
374
377
}
375
378
}
0 commit comments