File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 11use anyhow:: Result ;
2+ use tracing:: debug;
23
34use crate :: connection:: Connection ;
5+ use crate :: debugger:: handler:: { HandleResult , NextAction } ;
46
57mod handler;
68
@@ -9,9 +11,25 @@ pub struct CairoDebugger {
911}
1012
1113impl CairoDebugger {
12- pub fn connect ( ) -> Result < Self > {
14+ pub fn connect_and_initialize ( ) -> Result < Self > {
1315 let connection = Connection :: new ( ) ?;
14- Ok ( Self { connection } )
16+ let debugger = Self { connection } ;
17+ debugger. initialize ( ) ?;
18+
19+ Ok ( debugger)
20+ }
21+
22+ fn initialize ( & self ) -> Result < ( ) > {
23+ loop {
24+ // TODO(#35)
25+ let request = self . connection . next_request ( ) ?;
26+ if let HandleResult :: Trigger ( NextAction :: FinishInit ) = self . handle_request ( request) ? {
27+ debug ! ( "Initialization finished" ) ;
28+ break ;
29+ }
30+ }
31+
32+ Ok ( ( ) )
1533 }
1634
1735 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