@@ -8,80 +8,117 @@ Safe and idiomatic Rust bindings for the [eCAL](https://github.com/eclipse-ecal/
88
99## Features
1010
11- - 📡 High-performance publish/subscribe middleware (based on eCAL)
12- - 🦀 Idiomatic Rust API over eCAL C-API
13- - 💬 Type-safe messaging for:
14- - ` StringMessage `
15- - ` BytesMessage `
16- - ` ProtobufMessage<T> ` (based on ` prost ` )
17- - 🧪 Works on Linux and Windows (via ` bindgen ` + ` cc ` )
18- - 📖 Modular message support via ` rustecal-types-* ` crates
11+ - Idiomatic Rust interface to the eCAL C API
12+ - Zero-copy shared memory transport
13+ - Type-safe publish/subscribe and service communication
14+ - Modular type support: String, Binary, Protobuf
15+ - Fully runtime-compatible with C++ eCAL systems
1916
2017---
2118
22- ## Usage
19+ ## Examples
2320
24- Add the following to your ` Cargo.toml ` :
25-
26- ``` toml
27- [dependencies ]
28- rustecal = { path = " path/to/rustecal" }
29- rustecal-types-string = { path = " path/to/rustecal-types-string" }
30- ```
31-
32- Example (sending a string message):
21+ ### Publisher
3322
3423``` rust
24+ use rustecal :: {Ecal , EcalComponents };
3525use rustecal :: pubsub :: Publisher ;
36- use rustecal :: types :: StringMessage ;
3726
38- let _ecal = rustecal :: Ecal :: initialize (" hello_send" )? ;
27+ fn main () -> Result <(), Box <dyn std :: error :: Error >> {
28+ Ecal :: initialize (Some (" rust publisher" ), EcalComponents :: DEFAULT )? ;
29+ let mut pub = Publisher :: <String >:: new (" chatter" )? ;
3930
40- let publisher = Publisher :: <StringMessage >:: builder (" hello_topic" ). create ()? ;
41- publisher . send (" Hello from Rust!" )? ;
31+ loop {
32+ pub . send (" Hello from Rust!" )? ;
33+ std :: thread :: sleep (std :: time :: Duration :: from_millis (500 ));
34+ }
35+ }
4236```
4337
44- Example (receiving a message):
38+ ---
39+
40+ ### Subscriber
4541
4642``` rust
43+ use rustecal :: {Ecal , EcalComponents };
4744use rustecal :: pubsub :: Subscriber ;
48- use rustecal :: types :: StringMessage ;
4945
50- let _ecal = rustecal :: Ecal :: initialize (" hello_receive" )? ;
46+ fn main () -> Result <(), Box <dyn std :: error :: Error >> {
47+ Ecal :: initialize (Some (" rust subscriber" ), EcalComponents :: DEFAULT )? ;
48+ let sub = Subscriber :: <String >:: new (" chatter" )? ;
49+
50+ sub . set_callback (| msg | {
51+ println! (" Received: {}" , msg . payload);
52+ })? ;
5153
52- let subscriber = Subscriber :: < StringMessage > :: builder ( " hello_topic " ) . create () ? ;
53- subscriber . set_callback ( | msg | {
54- println! ( " Received: {} " , msg . data ());
55- });
54+ loop {
55+ std :: thread :: sleep ( std :: time :: Duration :: from_millis ( 100 ));
56+ }
57+ }
5658```
5759
5860---
5961
60- ## Crate Structure
62+ ### Service Server
6163
62- - ` rustecal ` : core eCAL bindings and idiomatic API
63- - ` rustecal-sys ` : low-level ` bindgen ` generated FFI bindings
64- - ` rustecal-types-string ` , ` rustecal-types-bytes ` , ` rustecal-types-protobuf ` : message wrapper crates
64+ ``` rust
65+ use rustecal :: {Ecal , EcalComponents };
66+ use rustecal :: service :: server :: ServiceServer ;
67+ use rustecal :: service :: types :: MethodInfo ;
68+
69+ fn main () -> Result <(), Box <dyn std :: error :: Error >> {
70+ Ecal :: initialize (Some (" mirror server" ), EcalComponents :: DEFAULT )? ;
71+ let mut server = ServiceServer :: new (" mirror" )? ;
72+
73+ server . add_method (" reverse" , Box :: new (| _info : MethodInfo , req : & [u8 ]| {
74+ let mut reversed = req . to_vec ();
75+ reversed . reverse ();
76+ reversed
77+ }))? ;
78+
79+ loop {
80+ std :: thread :: sleep (std :: time :: Duration :: from_millis (100 ));
81+ }
82+ }
83+ ```
6584
6685---
6786
68- ## Documentation
69-
70- 📚 Full user guide: [ https://rex-schilasky.github.io/rustecal ] ( https://rex-schilasky.github.io/rustecal )
87+ ### Service Client
7188
72- ``` bash
73- cd docs/
74- mdbook serve
89+ ``` rust
90+ use rustecal :: {Ecal , EcalComponents };
91+ use rustecal :: service :: client :: ServiceClient ;
92+ use rustecal :: service :: types :: ServiceRequest ;
93+
94+ fn main () -> Result <(), Box <dyn std :: error :: Error >> {
95+ Ecal :: initialize (Some (" mirror client" ), EcalComponents :: DEFAULT )? ;
96+ let client = ServiceClient :: new (" mirror" )? ;
97+
98+ let request = ServiceRequest {
99+ payload : b " stressed" . to_vec (),
100+ };
101+
102+ if let Some (response ) = client . call (" reverse" , request , Some (1000 )) {
103+ println! (" Reversed: {}" , String :: from_utf8_lossy (& response . payload));
104+ } else {
105+ println! (" No response received." );
106+ }
107+
108+ Ok (())
109+ }
75110```
76111
77112---
78113
79- ## License
114+ ## Documentation
80115
81- Licensed under Apache-2.0 or MIT.
116+ - 📘 API Docs: [ docs.rs/rustecal] ( https://docs.rs/rustecal )
117+ - 📖 Guide & Examples: see ` docs/ ` (mdBook)
82118
83119---
84120
85- ## Maintainer
121+ ## License
86122
87- [ Rex Schilasky] ( https://github.com/rex-schilasky )
123+ Licensed under the Apache License 2.0 (see [ LICENSE] ( ./LICENSE ) )
124+ © 2024–2025 Eclipse Contributors / Rex Schilasky
0 commit comments