Skip to content

Commit debaefd

Browse files
authored
Migrate to Rust Edition 2024 (#76)
* update dependencies * update edition to 2024 across all Cargo.toml files * cargo fmt with edition 2024 * use unsafe blocks in unsafe extern "C" functions
1 parent 35ec3af commit debaefd

File tree

33 files changed

+47
-54
lines changed

33 files changed

+47
-54
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[workspace]
2+
resolver = "3"
23
members = [
34
"rustecal",
45
"rustecal-core",
@@ -23,5 +24,5 @@ members = [
2324
"rustecal-samples/pubsub/serde_receive",
2425
"rustecal-samples/service/mirror_client",
2526
"rustecal-samples/service/mirror_client_instances",
26-
"rustecal-samples/service/mirror_server"
27-
]
27+
"rustecal-samples/service/mirror_server",
28+
]

rustecal-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rustecal-core"
33
version = "0.1.6"
44
authors = ["Rex Schilasky"]
5-
edition = "2021"
5+
edition = "2024"
66
description = "Core API for Eclipse eCAL"
77
license = "Apache-2.0"
88
repository = "https://github.com/eclipse-ecal/rustecal"

rustecal-core/src/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::ptr;
1818

1919
use crate::components::EcalComponents;
2020
use crate::configuration::Configuration;
21-
use crate::error::{check, RustecalError};
21+
use crate::error::{RustecalError, check};
2222
use crate::types::Version;
2323

2424
/// Provides access to the core initialization, shutdown, and state‑checking functions of eCAL.

rustecal-pubsub/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rustecal-pubsub"
33
version = "0.1.7"
44
authors = ["Rex Schilasky"]
5-
edition = "2021"
5+
edition = "2024"
66
description = "Publish/Subscribe API for Eclipse eCAL"
77
license = "Apache-2.0"
88
repository = "https://github.com/eclipse-ecal/rustecal"

rustecal-pubsub/src/payload_writer.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ thread_local! {
3333
pub(crate) unsafe extern "C" fn write_full_cb(buffer: *mut c_void, size: usize) -> c_int {
3434
CURRENT_WRITER.with(|cell| {
3535
if let Some(writer_ptr) = *cell.borrow() {
36-
let writer: &mut dyn PayloadWriter = &mut *writer_ptr;
37-
let buf = std::slice::from_raw_parts_mut(buffer as *mut u8, size);
38-
if writer.write_full(buf) {
39-
0
40-
} else {
41-
-1
42-
}
36+
let writer: &mut dyn PayloadWriter = unsafe { &mut *writer_ptr };
37+
let buf = unsafe { std::slice::from_raw_parts_mut(buffer as *mut u8, size) };
38+
if writer.write_full(buf) { 0 } else { -1 }
4339
} else {
4440
-1
4541
}
@@ -50,13 +46,9 @@ pub(crate) unsafe extern "C" fn write_full_cb(buffer: *mut c_void, size: usize)
5046
pub(crate) unsafe extern "C" fn write_mod_cb(buffer: *mut c_void, size: usize) -> c_int {
5147
CURRENT_WRITER.with(|cell| {
5248
if let Some(writer_ptr) = *cell.borrow() {
53-
let writer: &mut dyn PayloadWriter = &mut *writer_ptr;
54-
let buf = std::slice::from_raw_parts_mut(buffer as *mut u8, size);
55-
if writer.write_modified(buf) {
56-
0
57-
} else {
58-
-1
59-
}
49+
let writer: &mut dyn PayloadWriter = unsafe { &mut *writer_ptr };
50+
let buf = unsafe { std::slice::from_raw_parts_mut(buffer as *mut u8, size) };
51+
if writer.write_modified(buf) { 0 } else { -1 }
6052
} else {
6153
-1
6254
}
@@ -67,7 +59,7 @@ pub(crate) unsafe extern "C" fn write_mod_cb(buffer: *mut c_void, size: usize) -
6759
pub(crate) unsafe extern "C" fn get_size_cb() -> usize {
6860
CURRENT_WRITER.with(|cell| {
6961
if let Some(writer_ptr) = *cell.borrow() {
70-
let writer: &mut dyn PayloadWriter = &mut *writer_ptr;
62+
let writer: &mut dyn PayloadWriter = unsafe { &mut *writer_ptr };
7163
writer.get_size()
7264
} else {
7365
0

rustecal-pubsub/src/publisher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::payload_writer::{
2-
get_size_cb, write_full_cb, write_mod_cb, PayloadWriter, CURRENT_WRITER,
2+
CURRENT_WRITER, PayloadWriter, get_size_cb, write_full_cb, write_mod_cb,
33
};
44
use crate::types::TopicId;
55
use rustecal_core::types::DataTypeInfo;

rustecal-pubsub/src/typed_subscriber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::types::TopicId;
33
use rustecal_core::types::DataTypeInfo;
44
use rustecal_sys::{eCAL_SDataTypeInformation, eCAL_SReceiveCallbackData, eCAL_STopicId};
55
use std::{
6-
ffi::{c_void, CStr},
6+
ffi::{CStr, c_void},
77
marker::PhantomData,
88
slice,
99
};

rustecal-samples/benchmarks/performance_receive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "performance_receive"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
rustecal = { path = "../../../rustecal", features = ["pubsub"] }

rustecal-samples/benchmarks/performance_receive/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustecal::{Ecal, EcalComponents, TypedSubscriber};
66
use rustecal_types_bytes::BytesMessage;
77
use std::thread::sleep;
88
use std::{
9-
sync::{atomic::Ordering, Arc, Mutex},
9+
sync::{Arc, Mutex, atomic::Ordering},
1010
thread,
1111
time::{Duration, Instant},
1212
};

rustecal-samples/benchmarks/performance_send/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "performance_send"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
rustecal = { path = "../../../rustecal", features = ["pubsub"] }

0 commit comments

Comments
 (0)