Skip to main content

Batches

Struct Batches 

Source
pub struct Batches<'a> { /* private fields */ }
Available on crate feature async only.
Expand description

Namespace handle for the Batches API.

Implementations§

Source§

impl<'a> Batches<'a>

Source

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).

Source

pub async fn get(&self, id: &str) -> Result<MessageBatch>

Fetch the current status of a batch by id.

Source

pub async fn list( &self, params: ListBatchesParams, ) -> Result<Paginated<MessageBatch>>

Fetch one page of batches.

Source

pub async fn list_all(&self) -> Result<Vec<MessageBatch>>

Fetch every batch, transparently paging.

Source

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.

Source

pub async fn delete(&self, id: &str) -> Result<BatchDeleted>

Delete a batch. Allowed only after the batch has ended.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more