## Module client

Source
Expand description

Clients to interact with Google Cloud Pub/Sub.

This module contains the primary entry points for the library, including clients for publishing messages and managing topics and subscriptions.

## §Example: Publishing Messages

    use google_cloud_pubsub::client::Client;
    use google_cloud_pubsub::model::PubsubMessage;

    // Create a client for creating publishers.
    let client = Client::builder().build().await?;

    // Create a publisher that handles batching for a specific topic.
    let publisher = client.publisher("projects/my-project/topics/my-topic").build();

    // Publish several messages.
    // The client will automatically batch them in the background.
    let mut handles = Vec::new();
    for i in 0..10 {
        let msg = PubsubMessage::new().set_data(format!("message {}", i));
        handles.push(publisher.publish(msg));
    }

    // The handles are futures that resolve to the server-assigned message IDs.
    // You can await them to get the results. Messages will still be sent even
    // if the handles are dropped.
    for (i, handle) in handles.into_iter().enumerate() {
        let message_id = handle.await?;
        println!("Message {} sent with ID: {}", i, message_id);
    }

## Structs§

Client
  Creates `Publisher` instances.
Publisher
  A `Publisher` sends messages to a specific topic. It manages message batching and sending in a background task.
SchemaService
  Implements a client for the Cloud Pub/Sub API.
Subscriber
  A Subscriber client for the Cloud Pub/Sub API.
SubscriptionAdmin
  Implements a client for the Cloud Pub/Sub API.
TopicAdmin
  Implements a client for the Cloud Pub/Sub API.