pub struct BasePublisher { /* private fields */ }Expand description
Creates Publisher instances.
A single BasePublisher can be used to create multiple Publisher clients
for different topics. It manages the underlying gRPC connection and
authentication.
§Example
// Create a client.
let client: BasePublisher = BasePublisher::builder().build().await?;
// Create a publisher for a specific topic.
let publisher = client.publisher("projects/my-project/topics/my-topic").build();
// Publish a message.
let handle = publisher.publish(Message::new().set_data("hello world"));
let message_id = handle.await?;
println!("Message sent with ID: {}", message_id);Implementations§
Source§impl BasePublisher
impl BasePublisher
Sourcepub fn builder() -> BasePublisherBuilder
pub fn builder() -> BasePublisherBuilder
Returns a builder for BasePublisher.
let client: BasePublisher = BasePublisher::builder().build().await?;Sourcepub fn publisher<T>(&self, topic: T) -> PublisherPartialBuilder
pub fn publisher<T>(&self, topic: T) -> PublisherPartialBuilder
Creates a new Publisher for a given topic.
let client = BasePublisher::builder().build().await?;
let publisher = client.publisher("projects/my-project/topics/my-topic").build();
let message_id = publisher.publish(Message::new().set_data("Hello, World")).await?;Trait Implementations§
Source§impl Clone for BasePublisher
impl Clone for BasePublisher
Source§fn clone(&self) -> BasePublisher
fn clone(&self) -> BasePublisher
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BasePublisher
impl !RefUnwindSafe for BasePublisher
impl Send for BasePublisher
impl Sync for BasePublisher
impl Unpin for BasePublisher
impl UnsafeUnpin for BasePublisher
impl !UnwindSafe for BasePublisher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request