pub struct Batches<'a> { /* private fields */ }async only.Expand description
Namespace handle for the Batches API.
Implementations§
Source§impl<'a> Batches<'a>
impl<'a> Batches<'a>
Sourcepub async fn create(&self, requests: Vec<BatchRequest>) -> Result<MessageBatch>
pub async fn create(&self, requests: Vec<BatchRequest>) -> Result<MessageBatch>
Submit a batch of BatchRequest entries. Returns the initial
MessageBatch status (typically processing_status: in_progress).
Sourcepub async fn get(&self, id: &str) -> Result<MessageBatch>
pub async fn get(&self, id: &str) -> Result<MessageBatch>
Fetch the current status of a batch by id.
Sourcepub async fn list(
&self,
params: ListBatchesParams,
) -> Result<Paginated<MessageBatch>>
pub async fn list( &self, params: ListBatchesParams, ) -> Result<Paginated<MessageBatch>>
Fetch one page of batches.
Sourcepub async fn list_all(&self) -> Result<Vec<MessageBatch>>
pub async fn list_all(&self) -> Result<Vec<MessageBatch>>
Fetch every batch, transparently paging.
Sourcepub async fn cancel(&self, id: &str) -> Result<MessageBatch>
pub async fn cancel(&self, id: &str) -> Result<MessageBatch>
Request cancellation of a batch. Already-running entries continue
until they finish; the batch transitions to Canceling and then
to Ended once those settle.
Sourcepub async fn delete(&self, id: &str) -> Result<BatchDeleted>
pub async fn delete(&self, id: &str) -> Result<BatchDeleted>
Delete a batch. Allowed only after the batch has ended.
Sourcepub async fn wait_for(
&self,
id: &str,
options: WaitOptions,
) -> Result<MessageBatch>
pub async fn wait_for( &self, id: &str, options: WaitOptions, ) -> Result<MessageBatch>
Poll Self::get until the batch’s processing_status is
ProcessingStatus::Ended (or any other terminal status the
server reports). Returns the final MessageBatch.
Honors WaitOptions::poll_interval between calls and
WaitOptions::timeout as an overall ceiling.
Sourcepub async fn results(&self, id: &str) -> Result<Vec<BatchResultItem>>
pub async fn results(&self, id: &str) -> Result<Vec<BatchResultItem>>
Fetch all batch results into a Vec. Convenience wrapper over
Self::results_stream for callers that don’t need streaming.
Sourcepub async fn results_stream(
&self,
id: &str,
) -> Result<BoxStream<'static, Result<BatchResultItem>>>
pub async fn results_stream( &self, id: &str, ) -> Result<BoxStream<'static, Result<BatchResultItem>>>
Stream the JSONL results body line-by-line, decoding each line as
a BatchResultItem. Returns immediately after the connection
is established; consumes lazily as the caller polls the stream.
Mid-stream connection failures are surfaced as stream items; retries are not applied (consistent with the SSE streaming design – silent retry would drop content).
Auto Trait Implementations§
impl<'a> Freeze for Batches<'a>
impl<'a> !RefUnwindSafe for Batches<'a>
impl<'a> Send for Batches<'a>
impl<'a> Sync for Batches<'a>
impl<'a> Unpin for Batches<'a>
impl<'a> UnsafeUnpin for Batches<'a>
impl<'a> !UnwindSafe for Batches<'a>
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more