Skip to content

Commit fa24a1a

Browse files
pubsub doc/samples aligned (#12)
1 parent f9d1d56 commit fa24a1a

File tree

20 files changed

+47
-35
lines changed

20 files changed

+47
-35
lines changed

docs/src/api/message_types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Used for binary `Vec<u8>` payloads.
1515
Supports publishing/receiving of Protobuf types that implement `Message` and `Default`.
1616

1717
```rust
18-
use rustecal::types::ProtobufMessage;
18+
use rustecal_types_protobuf::ProtobufMessage;
1919
use my_proto::MyProto;
2020

21-
let pub = Publisher::<ProtobufMessage<MyProto>>::builder("proto_topic").create()?;
21+
let publisher = Publisher::<ProtobufMessage<MyProto>>::builder("proto_topic").create()?;
2222
```

docs/src/api/publisher.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ The `Publisher<T>` allows you to publish messages of type `T` on a topic.
66

77
```rust
88
use rustecal::pubsub::Publisher;
9-
use rustecal::types::StringMessage;
9+
use rustecal_types::StringMessage;
1010

11-
let pub = Publisher::<StringMessage>::builder("my_topic").create()?;
12-
pub.send("Rust rocks!")?;
11+
let publisher = Publisher::<StringMessage>::builder("my_topic").create()?;
12+
publisher.send("Rust rocks!")?;
1313
```

docs/src/api/service_client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ match response {
4848

4949
## Runtime Compatibility
5050

51-
This API matches the usage and behavior of `mirror_client.cpp` in the eCAL C++ samples.
51+
This API is fully compatible with the C++ `mirror_client.cpp` and C `mirror_client_c.c` examples.

docs/src/api/service_server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ Response : desserts
4747

4848
## Runtime Compatibility
4949

50-
This API is fully compatible with the C++ `mirror_server.cpp` and C `mirror_server.c` examples.
50+
This API is fully compatible with the C++ `mirror_server.cpp` and C `mirror_server_c.c` examples.

docs/src/api/subscriber.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ The `Subscriber<T>` enables you to subscribe to messages of type `T` on a topic.
66

77
```rust
88
use rustecal::pubsub::Subscriber;
9-
use rustecal::types::StringMessage;
9+
use rustecal_types::StringMessage;
1010

11-
let sub = Subscriber::<StringMessage>::builder("my_topic").create()?;
12-
sub.set_callback(|msg| {
11+
let subscriber = Subscriber::<StringMessage>::builder("my_topic").create()?;
12+
subscriber.set_callback(|msg| {
1313
println!("Received: {}", msg.data());
1414
});
1515
```

docs/src/examples/binary.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Publisher
44

55
```rust
6+
use std::sync::Arc;
67
use rustecal::{Ecal, EcalComponents, TypedPublisher};
78
use rustecal_types_bytes::BytesMessage;
89

@@ -14,9 +15,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1415
let mut counter = 0u8;
1516
while Ecal::ok() {
1617
let buf = vec![counter; 1024];
18+
counter = counter.wrapping_add(1);
1719
publisher.send(&BytesMessage(Arc::from(buf)));
1820

19-
counter = counter.wrapping_add(1);
2021
std::thread::sleep(std::time::Duration::from_millis(500));
2122
}
2223

@@ -36,7 +37,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3637

3738
let mut subscriber = TypedSubscriber::<BytesMessage>::new("blob")?;
3839
subscriber.set_callback(|msg| {
39-
println!("Received blob of {} bytes", msg.msg.0.len());
40+
println!("Received blob of {} bytes", msg.payload.data.len());
4041
});
4142

4243
while Ecal::ok() {

docs/src/examples/protobuf.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4848
Ecal::initialize(Some("protobuf subscriber"), EcalComponents::DEFAULT)?;
4949

5050
let mut subscriber = TypedSubscriber::<ProtobufMessage<Person>>::new("person")?;
51-
subscriber.set_callback(|msg| println!("Received person: {}", msg.msg.0.name));
51+
subscriber.set_callback(|msg| {
52+
println!("Received person: {}", msg.payload.data.name)
53+
});
5254

5355
while Ecal::ok() {
5456
std::thread::sleep(std::time::Duration::from_millis(500));

docs/src/examples/service_client.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustecal::{Ecal, EcalComponents, ServiceClient, ServiceRequest};
99

1010
fn main() -> Result<(), Box<dyn std::error::Error>> {
1111
Ecal::initialize(Some("mirror_client"), EcalComponents::DEFAULT)?;
12-
println!("mirror_client initialized. Sending requests…");
1312

1413
let client = ServiceClient::new("mirror_service")?;
1514

docs/src/examples/string.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3333
Ecal::initialize(Some("string subscriber"), EcalComponents::DEFAULT)?;
3434

3535
let mut subscriber = TypedSubscriber::<StringMessage>::new("hello")?;
36-
subscriber.set_callback(|msg| println!("Received: {}", msg.msg.0));
36+
subscriber.set_callback(|msg| {
37+
println!("Received: {}", msg.payload.data)
38+
});
3739

3840
while Ecal::ok() {
3941
std::thread::sleep(std::time::Duration::from_millis(500));

docs/src/types/message_types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
- `BytesMessage` – Arbitrary binary data
44
- `StringMessage` – UTF-8 encoded strings
5-
- `ProtobufMessage<T>` – Protobuf messages (via `prost`)
5+
- `ProtobufMessage<T>` – Protobuf messages
66

77
Each type is provided via a dedicated crate to avoid pulling unnecessary dependencies.

0 commit comments

Comments
 (0)