diff --git a/api/pkg/apis/v1alpha1/providers/target/rust/rust_providers/uprotocol/Cargo.toml b/api/pkg/apis/v1alpha1/providers/target/rust/rust_providers/uprotocol/Cargo.toml index f34d3d0c9..fe1ebca4f 100644 --- a/api/pkg/apis/v1alpha1/providers/target/rust/rust_providers/uprotocol/Cargo.toml +++ b/api/pkg/apis/v1alpha1/providers/target/rust/rust_providers/uprotocol/Cargo.toml @@ -4,26 +4,26 @@ [package] name = "uprotocol" -version = "0.1.0" +version = "0.1.1" edition = { workspace = true } [lib] crate-type = ["cdylib"] [dependencies] -backon = { version = "1.5", default-features = false, features = ["tokio-sleep"] } +backon = { version = "1.6.0", default-features = false, features = ["tokio-sleep"] } symphony = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -tokio = { version = "1.45" } +tokio = { version = "1.52.3" } tracing = { workspace = true } tracing-subscriber = { workspace = true } -up-rust = { version = "0.7.1", default-features = false, features = ["communication", "util"] } -up-transport-mqtt5 = { version = "0.3" } -up-transport-zenoh = { version = "0.8" } +up-rust = { version = "0.9.0", default-features = false, features = ["communication", "util"] } +up-transport-mqtt5 = { version = "0.4.0" } +up-transport-zenoh = { version = "0.9.0" } [dev-dependencies] async-trait = { version = "0.1.88" } -test-case = { version = "3.3" } -test-log = { version = "0.2", features = ["trace"] } -up-rust = { version = "0.7.1", default-features = false, features = ["communication", "util", "test-util"] } +test-case = { version = "3.3.1" } +test-log = { version = "0.2.20", features = ["trace"] } +up-rust = { version = "0.9.0", default-features = false, features = ["communication", "util", "test-util"] } diff --git a/api/pkg/apis/v1alpha1/providers/target/rust/symphony/Cargo.toml b/api/pkg/apis/v1alpha1/providers/target/rust/symphony/Cargo.toml index c68375d51..65bb12c49 100644 --- a/api/pkg/apis/v1alpha1/providers/target/rust/symphony/Cargo.toml +++ b/api/pkg/apis/v1alpha1/providers/target/rust/symphony/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "symphony" -version = "0.1.4" +version = "0.1.5" edition = { workspace = true } license = "MIT" description = "Eclipse Symphony Target Provider Rust binding" @@ -15,9 +15,9 @@ keywords = ["orchestration"] crate-type = ["cdylib", "staticlib", "rlib"] [dependencies] -libloading = { version = "0.8" } +libloading = { version = "0.9" } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } -sha2 = { version = "0.10", default-features = false, features = ["std"]} +sha2 = { version = "0.11" } tracing = { workspace = true } tracing-subscriber = { workspace = true } diff --git a/api/pkg/apis/v1alpha1/providers/target/rust/symphony/src/lib.rs b/api/pkg/apis/v1alpha1/providers/target/rust/symphony/src/lib.rs index e0e488eca..962f6549d 100644 --- a/api/pkg/apis/v1alpha1/providers/target/rust/symphony/src/lib.rs +++ b/api/pkg/apis/v1alpha1/providers/target/rust/symphony/src/lib.rs @@ -5,25 +5,34 @@ */ use core::ffi::c_char; -use libloading::Library; -use sha2::{Digest, Sha256}; use std::collections::HashMap; use std::ffi::{CStr, CString}; use std::fs::File; -use std::io; +use std::io::Read; use std::ptr; + +use libloading::Library; +use sha2::{Digest, Sha256}; use tracing::{debug, error, warn}; pub mod models; use crate::models::*; /// Computes the SHA-256 hash of a file. -fn compute_sha256_hash(file_path: &str) -> Result { +fn compute_sha256_hash(file_path: &str) -> Result { let mut file = File::open(file_path)?; let mut hasher = Sha256::new(); - io::copy(&mut file, &mut hasher)?; + let mut buffer = [0u8; 8192]; + loop { + let n = file.read(&mut buffer)?; + if n == 0 { + break; + } + hasher.update(&buffer[..n]); + } let hash = hasher.finalize(); - Ok(format!("{:x}", hash)) + let hex_string: String = hash.iter().map(|b| format!("{b:02x}")).collect(); + Ok(hex_string) } /// Validates the computed hash against the expected hash value.