@@ -31,13 +31,38 @@ use std::sync::Arc;
3131
3232#[ derive( Debug , Clone , PartialEq , Eq ) ]
3333#[ cfg_attr( feature = "cli" , derive( clap:: ValueEnum ) ) ]
34- pub enum Operation {
34+ pub enum BeforeOperation {
35+ #[ cfg_attr( feature = "cli" , clap( name = "default_reset" ) ) ]
36+ DefaultReset ,
3537 #[ cfg_attr( feature = "cli" , clap( name = "no_reset" ) ) ]
36- None ,
38+ NoReset ,
39+ #[ cfg_attr( feature = "cli" , clap( name = "no_reset_no_sync" ) ) ]
40+ NoResetNoSync ,
41+ }
42+
43+ impl BeforeOperation {
44+ pub fn requires_reset ( & self ) -> bool {
45+ matches ! ( self , Self :: DefaultReset )
46+ }
47+
48+ pub fn should_download_stub ( & self ) -> bool {
49+ !matches ! ( self , Self :: NoResetNoSync )
50+ }
51+ }
52+
53+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
54+ #[ cfg_attr( feature = "cli" , derive( clap:: ValueEnum ) ) ]
55+ pub enum AfterOperation {
56+ #[ cfg_attr( feature = "cli" , clap( name = "no_reset" ) ) ]
57+ NoReset ,
3758 #[ cfg_attr( feature = "cli" , clap( name = "soft_reset" ) ) ]
3859 SoftReset ,
39- #[ cfg_attr( feature = "cli" , clap( name = "default_reset" ) ) ]
40- DefaultReset ,
60+ }
61+
62+ impl AfterOperation {
63+ pub fn requires_soft_reset ( & self ) -> bool {
64+ matches ! ( self , Self :: SoftReset )
65+ }
4166}
4267
4368#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -54,7 +79,7 @@ pub enum ChipType {
5479#[ derive( Clone ) ]
5580pub struct SifliToolBase {
5681 pub port_name : String ,
57- pub before : Operation ,
82+ pub before : BeforeOperation ,
5883 pub memory_type : String ,
5984 pub baud : u32 ,
6085 pub connect_attempts : i8 ,
@@ -67,7 +92,7 @@ impl SifliToolBase {
6792 /// 创建一个使用默认空进度回调的 SifliToolBase
6893 pub fn new_with_no_progress (
6994 port_name : String ,
70- before : Operation ,
95+ before : BeforeOperation ,
7196 memory_type : String ,
7297 baud : u32 ,
7398 connect_attempts : i8 ,
@@ -90,7 +115,7 @@ impl SifliToolBase {
90115 /// 创建一个使用自定义进度回调的 SifliToolBase
91116 pub fn new_with_progress (
92117 port_name : String ,
93- before : Operation ,
118+ before : BeforeOperation ,
94119 memory_type : String ,
95120 baud : u32 ,
96121 connect_attempts : i8 ,
0 commit comments