pub struct BatchesResource { /* private fields */ }
Expand description
Resource for managing message batches
Implementations§
Source§impl BatchesResource
impl BatchesResource
Sourcepub fn new(http_client: Arc<HttpClient>) -> Self
pub fn new(http_client: Arc<HttpClient>) -> Self
Create a new batches resource
Sourcepub async fn create(&self, params: BatchCreateParams) -> Result<MessageBatch>
pub async fn create(&self, params: BatchCreateParams) -> Result<MessageBatch>
Sourcepub async fn get(&self, batch_id: &str) -> Result<MessageBatch>
pub async fn get(&self, batch_id: &str) -> Result<MessageBatch>
Sourcepub async fn cancel(&self, batch_id: &str) -> Result<MessageBatch>
pub async fn cancel(&self, batch_id: &str) -> Result<MessageBatch>
Sourcepub async fn get_results(&self, batch_id: &str) -> Result<Vec<BatchResult>>
pub async fn get_results(&self, batch_id: &str) -> Result<Vec<BatchResult>>
Sourcepub async fn wait_for_completion(
&self,
batch_id: &str,
poll_interval: Option<Duration>,
timeout: Option<Duration>,
) -> Result<MessageBatch>
pub async fn wait_for_completion( &self, batch_id: &str, poll_interval: Option<Duration>, timeout: Option<Duration>, ) -> Result<MessageBatch>
Wait for a batch to complete
§Arguments
batch_id
- The ID of the batch to wait forpoll_interval
- How often to check the status (default: 5 seconds)timeout
- Maximum time to wait (default: 1 hour)
§Returns
The completed MessageBatch
object
§Errors
Returns an error if the batch fails, expires, or if the timeout is reached
Sourcepub async fn get_status(
&self,
batch_id: &str,
) -> Result<(BatchStatus, f64, u32)>
pub async fn get_status( &self, batch_id: &str, ) -> Result<(BatchStatus, f64, u32)>
Source§impl BatchesResource
High-level batch processing utilities
impl BatchesResource
High-level batch processing utilities
Sourcepub async fn create_and_wait(
&self,
params: BatchCreateParams,
poll_interval: Option<Duration>,
) -> Result<(MessageBatch, Vec<BatchResult>)>
pub async fn create_and_wait( &self, params: BatchCreateParams, poll_interval: Option<Duration>, ) -> Result<(MessageBatch, Vec<BatchResult>)>
Create and monitor a batch until completion
§Arguments
params
- Parameters for creating the batchpoll_interval
- How often to check status (default: 5 seconds)
§Returns
A tuple containing the completed batch and its results
§Errors
Returns an error if batch creation, processing, or result retrieval fails
Sourcepub async fn monitor_progress<F>(
&self,
batch_id: &str,
progress_callback: F,
poll_interval: Option<Duration>,
) -> Result<MessageBatch>
pub async fn monitor_progress<F>( &self, batch_id: &str, progress_callback: F, poll_interval: Option<Duration>, ) -> Result<MessageBatch>
Trait Implementations§
Source§impl Clone for BatchesResource
impl Clone for BatchesResource
Source§fn clone(&self) -> BatchesResource
fn clone(&self) -> BatchesResource
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 BatchesResource
impl !RefUnwindSafe for BatchesResource
impl Send for BatchesResource
impl Sync for BatchesResource
impl Unpin for BatchesResource
impl !UnwindSafe for BatchesResource
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