Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.06 KB

File metadata and controls

51 lines (37 loc) · 1.06 KB

Service Client

The ServiceClient API allows a Rust application to call eCAL services, either generically or per-instance.

Connecting to a Service

use rustecal::service::client::ServiceClient;

let client = ServiceClient::new("mirror")?;

Calling Methods

use rustecal::service::types::ServiceRequest;

let request = ServiceRequest {
    payload: b"stressed".to_vec(),
};

let response = client.call("echo", request, Some(1000));

To call all connected instances:

for instance in client.get_client_instances() {
    let response = instance.call("reverse", request.clone(), Some(1000));
}

Return Handling

match response {
    Some(res) if res.success => {
        println!("Response: {}", String::from_utf8_lossy(&res.payload));
    }
    Some(res) => {
        println!("Error: {}", res.error_msg.unwrap_or("Unknown error".into()));
    }
    None => {
        println!("No response or timeout.");
    }
}

Runtime Compatibility

This API matches the usage and behavior of mirror_client.cpp in the eCAL C++ samples.