Skip to main content

PostBinary

Trait PostBinary 

Source
pub trait PostBinary:
    Post
    + Serialize
    + Sync
    + Send {
    // Provided methods
    fn get_response_bytes(
        &self,
        client: &Client,
        base_url: &str,
        options: &RequestOptions,
    ) -> impl Future<Output = Result<Vec<u8>, OapiError>> + Send + Sync { ... }
    fn get_stream_response_bytes(
        &self,
        client: &Client,
        base_url: &str,
        options: &RequestOptions,
    ) -> impl Future<Output = Result<impl Stream<Item = Result<Vec<u8>, OapiError>> + Send + Unpin + 'static, OapiError>> + Send + Sync { ... }
}
Expand description

Trait for POST requests whose response body is binary rather than JSON.

Endpoints such as POST /audio/speech return the raw audio bytes instead of a JSON object, so the body is returned as raw bytes.

Provided Methods§

Source

fn get_response_bytes( &self, client: &Client, base_url: &str, options: &RequestOptions, ) -> impl Future<Output = Result<Vec<u8>, OapiError>> + Send + Sync

Sends a POST request with a JSON body and returns the raw response body bytes.

The client is supplied by the caller; see crate::rest::default_client for a sensible default.

Source

fn get_stream_response_bytes( &self, client: &Client, base_url: &str, options: &RequestOptions, ) -> impl Future<Output = Result<impl Stream<Item = Result<Vec<u8>, OapiError>> + Send + Unpin + 'static, OapiError>> + Send + Sync

Sends a POST request with a JSON body and streams the raw response body as byte chunks.

Unlike Self::get_response_bytes, the body is not buffered: each item is one transport-level chunk. This matches the official SDK’s streaming binary responses (e.g. POST /audio/speech with stream_format, where the chunks carry either raw audio or SSE frames). Parsing any framing inside the byte stream is up to the caller.

The client is supplied by the caller; see crate::rest::default_client for a sensible default.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§