pulsar-rs
pulsar-rs copied to clipboard
Concretize types for client building
The Pulsar consumer builder is generic over DeserializeMessage but the async Pulsar client building seems to require concrete types.
let client = pulsar::Pulsar::builder("pulsar://localhost:6650", TokioExecutor)
.build()
.await
.expect("Failed to create Pulsar client");
# type TestData = String;
let mut consumer: Consumer<TestData, _> = client
.consumer()
.with_topic("non-persistent://public/default/test")
.with_consumer_name("test_consumer")
.with_subscription("test_subscription")
.build() // works with string type
.await?;
# type TestData = unknown; // toy generic example
let mut consumer: Consumer<{unknown}, _> = client
.consumer()
.with_topic("non-persistent://public/default/test")
.with_consumer_name("test_consumer")
.with_subscription("test_subscription")
.build() // type inside `async` block must be known in this context
// cannot infer type for type parameter `T` declared on the method `build`
.await?;
Should the client builder build() accept trait objects?