Skip to content

Commit 703916c

Browse files
author
George Cosma
committed
wip: fix compilation erros and introduce async trait
Signed-off-by: George Cosma <george.cosma@wyliodrin.com>
1 parent 5e02614 commit 703916c

9 files changed

Lines changed: 33 additions & 410 deletions

File tree

tockloader-lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ bytes = "1.7.1"
1919
toml = "0.8.19"
2020
serde = { version = "1.0.210", features = ["derive"] }
2121
thiserror = "1.0.63"
22+
async-trait = "0.1.88"

tockloader-lib/src/command_impl/probers/info.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use async_trait::async_trait;
2+
13
use crate::attributes::app_attributes::AppAttributes;
24
use crate::attributes::general_attributes::GeneralAttributes;
35
use crate::attributes::system_attributes::SystemAttributes;
@@ -6,6 +8,7 @@ use crate::connection::{Connection, ProbeRSConnection};
68
use crate::errors::TockloaderError;
79
use crate::CommandInfo;
810

11+
#[async_trait]
912
impl CommandInfo for ProbeRSConnection {
1013
async fn info(
1114
&mut self,

tockloader-lib/src/command_impl/probers/install.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use async_trait::async_trait;
12
use probe_rs::flashing::DownloadOptions;
23
use probe_rs::MemoryInterface;
34
use tbf_parser::parse::parse_tbf_header_lengths;
@@ -8,6 +9,7 @@ use crate::errors::TockloaderError;
89
use crate::tabs::tab::Tab;
910
use crate::CommandInstall;
1011

12+
#[async_trait]
1113
impl CommandInstall for ProbeRSConnection {
1214
async fn install_app(
1315
&mut self,

tockloader-lib/src/command_impl/probers/list.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
use async_trait::async_trait;
2+
13
use crate::attributes::app_attributes::AppAttributes;
24
use crate::board_settings::BoardSettings;
35
use crate::connection::{Connection, ProbeRSConnection};
46
use crate::errors::TockloaderError;
57
use crate::CommandList;
68

9+
#[async_trait]
710
impl CommandList for ProbeRSConnection {
811
async fn list(
912
&mut self,

tockloader-lib/src/command_impl/serial/info.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::time::Duration;
22

3+
use async_trait::async_trait;
4+
35
use crate::attributes::app_attributes::AppAttributes;
46
use crate::attributes::general_attributes::GeneralAttributes;
57
use crate::attributes::system_attributes::SystemAttributes;
@@ -9,6 +11,7 @@ use crate::connection::{Connection, SerialConnection};
911
use crate::errors::TockloaderError;
1012
use crate::CommandInfo;
1113

14+
#[async_trait]
1215
impl CommandInfo for SerialConnection {
1316
async fn info(
1417
&mut self,

tockloader-lib/src/command_impl/serial/install.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
use async_trait::async_trait;
2+
13
use crate::board_settings::BoardSettings;
24
use crate::connection::SerialConnection;
35
use crate::errors::TockloaderError;
46
use crate::tabs::tab::Tab;
57
use crate::CommandInstall;
68

9+
#[async_trait]
710
impl CommandInstall for SerialConnection {
811
async fn install_app(
912
&mut self,

tockloader-lib/src/command_impl/serial/list.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
use std::time::Duration;
22

3+
use async_trait::async_trait;
4+
35
use crate::attributes::app_attributes::AppAttributes;
46
use crate::board_settings::BoardSettings;
57
use crate::bootloader_serial::{ping_bootloader_and_wait_for_response, Response};
68
use crate::connection::{Connection, SerialConnection};
79
use crate::errors::TockloaderError;
810
use crate::CommandList;
911

12+
#[async_trait]
1013
impl CommandList for SerialConnection {
1114
async fn list(
1215
&mut self,

tockloader-lib/src/connection.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::time::Duration;
22

3+
use async_trait::async_trait;
34
use probe_rs::probe::DebugProbeInfo;
45
use probe_rs::{Permissions, Session};
56
use tokio::io::AsyncWriteExt;
@@ -47,6 +48,7 @@ impl Default for SerialTargetInfo {
4748
}
4849
}
4950

51+
#[async_trait]
5052
pub 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]
7881
impl 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]
124128
impl 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

Comments
 (0)