| Crates.io | rustecal-types-protobuf |
| lib.rs | rustecal-types-protobuf |
| version | 0.1.6 |
| created_at | 2025-05-24 19:07:35.54054+00 |
| updated_at | 2025-08-30 19:17:16.293287+00 |
| description | Google Protobuf type support for rustecal TypedPublisher/TypedSubscriber |
| homepage | |
| repository | https://github.com/eclipse-ecal/rustecal |
| max_upload_size | |
| id | 1687697 |
| size | 32,190 |
rustecal-types-protobuf provides a helper wrapper for Protobuf messages (using prost) to use with the typed eCAL Pub/Sub API.
PublisherMessage and SubscriberMessage for seamless integrationArc::from(ProtobufMessage)include_bytes! (optional)prost, rustecal-core and rustecal-pubsubAdd to your workspace Cargo.toml:
[dependencies]
rustecal-types-protobuf = "0.1"
use rustecal::{Ecal, EcalComponents, TypedPublisher};
use rustecal_types_protobuf::{ProtobufMessage, IsProtobufType};
mod people { include!(concat!(env!("OUT_DIR"), "/pb.people.rs")); }
mod animal { include!(concat!(env!("OUT_DIR"), "/pb.animal.rs")); }
mod environment { include!(concat!(env!("OUT_DIR"), "/pb.environment.rs")); }
use people::Person;
impl IsProtobufType for Person {}
fn main() -> Result<(), Box<dyn std::error::Error>> {
Ecal::initialize(Some("protobuf publisher"), EcalComponents::DEFAULT, None)?;
let publisher = TypedPublisher::<ProtobufMessage<Person>>::new("person")?;
while Ecal::ok() {
let person = Person { id: 1, name: "Alice".into(), ..Default::default() };
let message = ProtobufMessage { data : person.into() };
publisher.send(&message, Timestamp::Auto);
std::thread::sleep(std::time::Duration::from_millis(500));
}
Ecal::finalize();
Ok(())
}
use rustecal::{Ecal, EcalComponents, TypedSubscriber};
use rustecal_types_protobuf::{ProtobufMessage, IsProtobufType};
mod people { include!(concat!(env!("OUT_DIR"), "/pb.people.rs")); }
mod animal { include!(concat!(env!("OUT_DIR"), "/pb.animal.rs")); }
mod environment { include!(concat!(env!("OUT_DIR"), "/pb.environment.rs")); }
use people::Person;
impl IsProtobufType for Person {}
fn main() -> Result<(), Box<dyn std::error::Error>> {
Ecal::initialize(Some("protobuf subscriber"), EcalComponents::DEFAULT, None)?;
let mut subscriber = TypedSubscriber::<ProtobufMessage<Person>>::new("person")?;
subscriber.set_callback(|message| {
println!("Received person: {}", message.payload.data.name)
});
while Ecal::ok() {
std::thread::sleep(std::time::Duration::from_millis(500));
}
Ecal::finalize();
Ok(())
}
PublisherMessage
datatype() -> DataTypeInfoto_bytes(&self) -> Arc<[u8]>SubscriberMessage
datatype() -> DataTypeInfofrom_bytes(bytes: Arc<[u8]>, _info: &DataTypeInfo) -> Option<Self>rustecal-types-bytes for raw binary data messagesrustecal-types-string for UTF-8 string messagesrustecal-types-serde for JSON/CBOR/MessagePack via Serderustecal-samples/pubsub directory