pub struct Client { /* private fields */ }Expand description
Creates Publisher instances.
This is the main entry point for the publisher API. A single Client
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 = Client::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(PubsubMessage::new().set_data("hello world"));
let message_id = handle.await?;
println!("Message sent with ID: {}", message_id);Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for Client.
let client = Client::builder().build().await?;Sourcepub fn publisher<T>(&self, topic: T) -> PublisherBuilder
pub fn publisher<T>(&self, topic: T) -> PublisherBuilder
Creates a new Publisher for a given topic.
let client = Client::builder().build().await?;
let publisher = client.publisher("projects/my-project/topics/my-topic").build();
let message_id = publisher.publish(PubsubMessage::new().set_data("Hello, World")).await?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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