11use std:: time:: Duration ;
22
3+ use async_trait:: async_trait;
34use probe_rs:: probe:: DebugProbeInfo ;
45use probe_rs:: { Permissions , Session } ;
56use tokio:: io:: AsyncWriteExt ;
@@ -47,6 +48,7 @@ impl Default for SerialTargetInfo {
4748 }
4849}
4950
51+ #[ async_trait]
5052pub trait Connection {
5153 async fn open ( & mut self ) -> Result < ( ) , TockloaderError > ;
5254 /// Closes the connection, if it is open. If it is not open, it does
@@ -75,6 +77,7 @@ impl ProbeRSConnection {
7577 }
7678}
7779
80+ #[ async_trait]
7881impl Connection for ProbeRSConnection {
7982 async fn open ( & mut self ) -> Result < ( ) , TockloaderError > {
8083 let probe = self
@@ -121,6 +124,7 @@ impl SerialConnection {
121124 }
122125}
123126
127+ #[ async_trait]
124128impl Connection for SerialConnection {
125129 async fn open ( & mut self ) -> Result < ( ) , TockloaderError > {
126130 let builder = tokio_serial:: new ( & self . port , self . target_info . baud_rate )
@@ -145,7 +149,7 @@ impl Connection for SerialConnection {
145149
146150 async fn close ( & mut self ) -> Result < ( ) , TockloaderError > {
147151 if let Some ( mut stream) = self . stream . take ( ) {
148- stream. shutdown ( ) . await ;
152+ stream. shutdown ( ) . await ? ;
149153 }
150154 Ok ( ( ) )
151155 }
0 commit comments