File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 11use anyhow:: Result ;
22
33use crate :: connection:: Connection ;
4+ use crate :: debugger:: handler:: { HandleResult , NextAction } ;
45
56mod handler;
67
@@ -9,9 +10,23 @@ pub struct CairoDebugger {
910}
1011
1112impl CairoDebugger {
12- pub fn connect ( ) -> Result < Self > {
13+ pub fn connect_and_initialize ( ) -> Result < Self > {
1314 let connection = Connection :: new ( ) ?;
14- Ok ( Self { connection } )
15+ let debugger = Self { connection } ;
16+ debugger. initialize ( ) ?;
17+
18+ Ok ( debugger)
19+ }
20+
21+ fn initialize ( & self ) -> Result < ( ) > {
22+ loop {
23+ let request = self . connection . next_request ( ) ?;
24+ if let HandleResult :: Trigger ( NextAction :: FinishInit ) = self . handle_request ( request) ? {
25+ break ;
26+ }
27+ }
28+
29+ Ok ( ( ) )
1530 }
1631
1732 pub fn run ( & self ) -> Result < ( ) > {
Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ use crate::CairoDebugger;
1212
1313pub enum HandleResult {
1414 Handled ,
15+ Trigger ( NextAction ) ,
16+ }
17+
18+ pub enum NextAction {
19+ FinishInit ,
1520}
1621
1722impl CairoDebugger {
@@ -86,7 +91,7 @@ impl CairoDebugger {
8691 Command :: ConfigurationDone => {
8792 trace ! ( "Configuration done" ) ;
8893 self . connection . send_success ( request, ResponseBody :: ConfigurationDone ) ?;
89- Ok ( HandleResult :: Handled )
94+ Ok ( HandleResult :: Trigger ( NextAction :: FinishInit ) )
9095 }
9196 Command :: Continue ( _) => {
9297 todo ! ( )
@@ -199,7 +204,6 @@ impl CairoDebugger {
199204 Ok ( HandleResult :: Handled )
200205 }
201206 Command :: Scopes ( _) => {
202- // Return no scopes.
203207 // Return no scopes.
204208 self . connection . send_success (
205209 request,
You can’t perform that action at this time.
0 commit comments