pub struct ImageData {
pub url: Option<String>,
pub b64_json: Option<String>,
pub revised_prompt: Option<String>,
}Expand description
Individual image data from generation response.
Fields§
§url: Option<String>URL of the generated image (if response_format = url) Note: URLs are only valid for 60 minutes after generation
b64_json: Option<String>Base64-encoded image data (if response_format = b64_json)
revised_prompt: Option<String>The revised prompt used by the model (DALL-E 3 only) DALL-E 3 may revise the original prompt for safety or quality
Implementations§
Source§impl ImageData
impl ImageData
Sourcepub fn as_bytes(&self) -> Option<Result<Vec<u8>, DecodeError>>
pub fn as_bytes(&self) -> Option<Result<Vec<u8>, DecodeError>>
Decodes base64 image data to bytes.
Returns None if no b64_json data is present.
Returns Some(Err(...)) if base64 decoding fails.
§Example
use openai_tools::images::response::ImageData;
use std::fs;
if let Some(bytes_result) = image_data.as_bytes() {
let bytes = bytes_result?;
fs::write("output.png", bytes)?;
}Trait Implementations§
Source§impl<'de> Deserialize<'de> for ImageData
impl<'de> Deserialize<'de> for ImageData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ImageData
impl RefUnwindSafe for ImageData
impl Send for ImageData
impl Sync for ImageData
impl Unpin for ImageData
impl UnwindSafe for ImageData
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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