diff --git a/rustecal-core/Cargo.toml b/rustecal-core/Cargo.toml index ac0937c..cfc5c00 100644 --- a/rustecal-core/Cargo.toml +++ b/rustecal-core/Cargo.toml @@ -1,21 +1,20 @@ [package] -name = "rustecal-core" -version = "0.1.2" -authors = ["Rex Schilasky"] -edition = "2021" -description = "Core API for Eclipse eCAL" -license = "Apache-2.0" -repository = "https://github.com/eclipse-ecal/rustecal" +name = "rustecal-core" +version = "0.1.2" +authors = ["Rex Schilasky"] +edition = "2021" +description = "Core API for Eclipse eCAL" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" documentation = "https://docs.rs/rustecal-core" -readme = "README.md" -keywords = ["ecal", "ipc", "pubsub", "server-client", "middleware"] -categories = ["network-programming", "api-bindings"] +readme = "README.md" +keywords = ["ecal", "ipc", "pubsub", "server-client", "middleware"] +categories = ["network-programming", "api-bindings"] [dependencies] -rustecal-sys = { version = "0.1.0", path = "../rustecal-sys", optional = true } -once_cell = "1.17" -thiserror = "1.0" -bitflags = "1.3" +rustecal-sys = { version = "0.1", path = "../rustecal-sys", optional = true } +thiserror = "2.0" +bitflags = "2.9" [features] # Include sys bindings by default in local builds @@ -25,4 +24,4 @@ sys = ["rustecal-sys"] [package.metadata.docs.rs] default-features = false -features = [] +features = [] diff --git a/rustecal-pubsub/Cargo.toml b/rustecal-pubsub/Cargo.toml index 0246f5b..913e86a 100644 --- a/rustecal-pubsub/Cargo.toml +++ b/rustecal-pubsub/Cargo.toml @@ -1,20 +1,19 @@ [package] -name = "rustecal-pubsub" -version = "0.1.3" -authors = ["Rex Schilasky"] -edition = "2021" -description = "Publish/Subscribe API for Eclipse eCAL" -license = "Apache-2.0" -repository = "https://github.com/eclipse-ecal/rustecal" +name = "rustecal-pubsub" +version = "0.1.3" +authors = ["Rex Schilasky"] +edition = "2021" +description = "Publish/Subscribe API for Eclipse eCAL" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" documentation = "https://docs.rs/rustecal-pubsub" -readme = "README.md" -keywords = ["ecal", "ipc", "pubsub", "middleware"] -categories = ["network-programming", "api-bindings"] +readme = "README.md" +keywords = ["ecal", "ipc", "publish-subscribe", "middleware"] +categories = ["network-programming", "api-bindings"] [dependencies] -rustecal-sys = { version = "0.1.0", path = "../rustecal-sys", optional = true } -rustecal-core = { version = "0.1.0", path = "../rustecal-core" } -thiserror = "1.0" +rustecal-sys = { version = "0.1", path = "../rustecal-sys", optional = true } +rustecal-core = { version = "0.1", path = "../rustecal-core" } [features] # Include sys bindings by default in local builds @@ -24,4 +23,4 @@ sys = ["rustecal-sys"] [package.metadata.docs.rs] default-features = false -features = [] +features = [] diff --git a/rustecal-pubsub/README.md b/rustecal-pubsub/README.md index 6e33b92..360e6df 100644 --- a/rustecal-pubsub/README.md +++ b/rustecal-pubsub/README.md @@ -25,7 +25,7 @@ rustecal-pubsub = "0.1" ## Quickstart -### Typed Publisher +### Typed Publisher Example ```rust use std::sync::Arc; @@ -49,7 +49,7 @@ fn main() -> Result<(), Box> { } ``` -### Typed Subscriber +### Typed Subscriber Example ```rust use rustecal::{Ecal, EcalComponents, TypedSubscriber}; diff --git a/rustecal-service/Cargo.toml b/rustecal-service/Cargo.toml index a221c68..9a66b58 100644 --- a/rustecal-service/Cargo.toml +++ b/rustecal-service/Cargo.toml @@ -1,15 +1,25 @@ [package] -name = "rustecal-service" -version = "0.1.0" -edition = "2021" +name = "rustecal-service" +version = "0.1.0" +authors = ["Rex Schilasky"] +edition = "2021" +description = "Server/Client API for Eclipse eCAL" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" +documentation = "https://docs.rs/rustecal-service" +readme = "README.md" +keywords = ["ecal", "ipc", "service", "server-client", "middleware"] +categories = ["network-programming", "api-bindings"] [dependencies] -rustecal-sys = { path = "../rustecal-sys" } -rustecal-core = { path = "../rustecal-core" } -thiserror = "1.0" -tokio = { version = "1", optional = true } +rustecal-sys = { version = "0.1", path = "../rustecal-sys", optional = true } [features] -default = ["async"] -async = ["tokio"] -sync = [] +# Include sys bindings by default in local builds +default = ["sys"] +# Optional feature to enable the rustecal-sys dependency +sys = ["rustecal-sys"] + +[package.metadata.docs.rs] +default-features = false +features = [] diff --git a/rustecal-service/README.md b/rustecal-service/README.md new file mode 100644 index 0000000..0faef26 --- /dev/null +++ b/rustecal-service/README.md @@ -0,0 +1,106 @@ +# rustecal-service + +`rustecal-service` provides a high-level RPC-style service server and client API, enabling request-response interactions with minimal boilerplate. + +## Features + +- **ServiceServer**: host one or more methods, register handlers via closures +- **ServiceClient**: invoke remote methods with optional timeouts +- **Method metadata** (`MethodInfo`) and structured responses (`ServiceResponse`) +- Built-in error handling and call-state reporting + +## Requirements + +- Rust 1.60 or later +- eCAL C/C++ library v6.0 or later installed on your system + +## Installation + +Add to your workspace `Cargo.toml`: + +```toml +[dependencies] +rustecal-service = "0.1" +``` + +## Quickstart + +### Server Example + +```rust +use rustecal::{Ecal, EcalComponents, ServiceServer}; +use rustecal::service::types::MethodInfo; + +fn main() -> Result<(), Box> { + Ecal::initialize(Some("mirror_server"), EcalComponents::DEFAULT)?; + + let mut server = ServiceServer::new("mirror_service")?; + + server.add_method("mirror", Box::new(|method: MethodInfo, req: &[u8]| { + let request_str = String::from_utf8_lossy(req); + println!("Received [{}] request: {}", method.method_name, request_str); + + // Echo (mirror) the same bytes back + req.to_vec() + }))?; + + println!("mirror_service is running…"); + + while Ecal::ok() { + std::thread::sleep(std::time::Duration::from_millis(500)); + } + + Ecal::finalize(); + Ok(()) +} +``` + + +### Client Example + +```rust +use rustecal::{Ecal, EcalComponents, ServiceClient, ServiceRequest}; + +fn main() -> Result<(), Box> { + Ecal::initialize(Some("mirror_client"), EcalComponents::DEFAULT)?; + + let client = ServiceClient::new("mirror_service")?; + + let request_data = b"Hello, Service!"; + let timeout = Some(500); + + while Ecal::ok() { + let request = ServiceRequest { + payload: request_data.to_vec(), + }; + + // Call the "mirror" method + if let Some(response) = client.call("mirror", request, timeout) { + // Extract the echoed payload + let echoed = String::from_utf8_lossy(&response.payload); + println!("Received response: {}", echoed); + } else { + println!("Service call timed out."); + } + + std::thread::sleep(std::time::Duration::from_millis(500)); + } + + Ecal::finalize(); + Ok(()) +} +``` + +## Traits Reference + +- **`ServiceServer`** + - `new(topic: &str) -> Result` + - `add_method(method: &str, callback: ServiceCallback) -> Result<(), String>` + +- **`ServiceClient`** + - `new(service_name: &str) -> Result` + - `call(method: &str, req: ServiceRequest, timeout_ms: Option) -> Option` + +## See Also + +- Examples in the `rustecal-samples/service` directory diff --git a/rustecal-sys/Cargo.toml b/rustecal-sys/Cargo.toml index 6368f89..38fc4ee 100644 --- a/rustecal-sys/Cargo.toml +++ b/rustecal-sys/Cargo.toml @@ -1,27 +1,24 @@ [package] -name = "rustecal-sys" -version = "0.1.2" -authors = ["Rex Schilasky"] -edition = "2021" -build = "build.rs" -description = "Raw FFI bindings to Eclipse eCAL C API" -license = "Apache-2.0" -repository = "https://github.com/eclipse-ecal/rustecal" +name = "rustecal-sys" +version = "0.1.2" +authors = ["Rex Schilasky"] +edition = "2021" +build = "build.rs" +description = "Raw FFI bindings to Eclipse eCAL C API" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" documentation = "https://docs.rs/rustecal-sys" -readme = "README.md" -keywords = ["ecal", "ipc", "pubsub", "server-client", "middleware"] -categories = ["network-programming", "api-bindings"] +readme = "README.md" +keywords = ["ecal", "ipc", "pubsub", "server-client", "middleware"] +categories = ["network-programming", "api-bindings"] [build-dependencies] -bindgen = "0.71.0" - -[dependencies] -libc = "0.2" +bindgen = "0.71" [features] default = ["dynamic"] dynamic = [] # Link dynamically to libecal_c -static = [] # Optional: Static linking (if you add support) +static = [] # Optional: Static linking (if you add support) [package.metadata.docs.rs] features = ["dynamic"] diff --git a/rustecal-types-bytes/Cargo.toml b/rustecal-types-bytes/Cargo.toml index 47f03d5..9ddb37a 100644 --- a/rustecal-types-bytes/Cargo.toml +++ b/rustecal-types-bytes/Cargo.toml @@ -1,16 +1,16 @@ [package] -name = "rustecal-types-bytes" -version = "0.1.2" -authors = ["Rex Schilasky"] -edition = "2021" -description = "Vec type support for rustecal TypedPublisher / TypedSubscriber" -license = "Apache-2.0" -repository = "https://github.com/eclipse-ecal/rustecal" +name = "rustecal-types-bytes" +version = "0.1.2" +authors = ["Rex Schilasky"] +edition = "2021" +description = "Vec type support for rustecal TypedPublisher/TypedSubscriber" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" documentation = "https://docs.rs/rustecal-types-bytes" -readme = "README.md" -keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] -categories = ["network-programming", "api-bindings"] +readme = "README.md" +keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] +categories = ["network-programming", "api-bindings"] [dependencies] -rustecal-core = { version = "0.1.0", path = "../rustecal-core" } -rustecal-pubsub = { version = "0.1.0", path = "../rustecal-pubsub" } +rustecal-core = { version = "0.1", path = "../rustecal-core" } +rustecal-pubsub = { version = "0.1", path = "../rustecal-pubsub" } diff --git a/rustecal-types-protobuf/Cargo.toml b/rustecal-types-protobuf/Cargo.toml index b88649f..9f61098 100644 --- a/rustecal-types-protobuf/Cargo.toml +++ b/rustecal-types-protobuf/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "rustecal-types-protobuf" -version = "0.1.0" -authors = ["Rex Schilasky"] -edition = "2021" -description = "Google Protobuf type support for rustecal TypedPublisher / TypedSubscriber" -license = "Apache-2.0" -repository = "https://github.com/eclipse-ecal/rustecal" +name = "rustecal-types-protobuf" +version = "0.1.0" +authors = ["Rex Schilasky"] +edition = "2021" +description = "Google Protobuf type support for rustecal TypedPublisher/TypedSubscriber" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" documentation = "https://docs.rs/rustecal-types-protobuf" -readme = "README.md" -keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] -categories = ["network-programming", "api-bindings"] +readme = "README.md" +keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] +categories = ["network-programming", "api-bindings"] [dependencies] -prost = "0.13.5" -rustecal-core = { version = "0.1.0", path = "../rustecal-core" } -rustecal-pubsub = { version = "0.1.0", path = "../rustecal-pubsub" } +prost = "0.13" +rustecal-core = { version = "0.1", path = "../rustecal-core" } +rustecal-pubsub = { version = "0.1", path = "../rustecal-pubsub" } diff --git a/rustecal-types-serde/Cargo.toml b/rustecal-types-serde/Cargo.toml index 33e0ea7..eb90bf4 100644 --- a/rustecal-types-serde/Cargo.toml +++ b/rustecal-types-serde/Cargo.toml @@ -1,19 +1,19 @@ [package] -name = "rustecal-types-serde" -version = "0.1.0" -edition = "2021" -description = "JSON/CBOR/MessagePack support for rustecal TypedPublisher / TypedSubscriber" -license = "Apache-2.0" -repository = "https://github.com/eclipse-ecal/rustecal" +name = "rustecal-types-serde" +version = "0.1.0" +edition = "2021" +description = "JSON/CBOR/MessagePack type support for rustecal TypedPublisher/TypedSubscriber" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" documentation = "https://docs.rs/rustecal-types-serde" -readme = "README.md" -keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] -categories = ["network-programming", "api-bindings"] +readme = "README.md" +keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] +categories = ["network-programming", "api-bindings"] [dependencies] -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -serde_cbor = "0.11" -rmp-serde = "1.1" -rustecal-core = { version = "0.1.0", path = "../rustecal-core" } -rustecal-pubsub = { version = "0.1.0", path = "../rustecal-pubsub" } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +serde_cbor = "0.11" +rmp-serde = "1.3" +rustecal-core = { version = "0.1", path = "../rustecal-core" } +rustecal-pubsub = { version = "0.1", path = "../rustecal-pubsub" } diff --git a/rustecal-types-string/Cargo.toml b/rustecal-types-string/Cargo.toml index 7d4c001..ae87c37 100644 --- a/rustecal-types-string/Cargo.toml +++ b/rustecal-types-string/Cargo.toml @@ -1,16 +1,16 @@ [package] -name = "rustecal-types-string" -version = "0.1.0" -authors = ["Rex Schilasky"] -edition = "2021" -description = "String type support for rustecal TypedPublisher / TypedSubscriber" -license = "Apache-2.0" -repository = "https://github.com/eclipse-ecal/rustecal" +name = "rustecal-types-string" +version = "0.1.0" +authors = ["Rex Schilasky"] +edition = "2021" +description = "String type support for rustecal TypedPublisher/TypedSubscriber" +license = "Apache-2.0" +repository = "https://github.com/eclipse-ecal/rustecal" documentation = "https://docs.rs/rustecal-types-string" -readme = "README.md" -keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] -categories = ["network-programming", "api-bindings"] +readme = "README.md" +keywords = ["ecal", "ipc", "pubsub", "message-support", "middleware"] +categories = ["network-programming", "api-bindings"] [dependencies] -rustecal-core = { version = "0.1.0", path = "../rustecal-core" } -rustecal-pubsub = { version = "0.1.0", path = "../rustecal-pubsub" } +rustecal-core = { version = "0.1", path = "../rustecal-core" } +rustecal-pubsub = { version = "0.1", path = "../rustecal-pubsub" }