Struct Image

Source
pub struct Image {
    pub image: Option<(String, Vec<u8>)>,
    pub mask: Option<(String, Vec<u8>)>,
    pub prompt: Option<String>,
    pub n: Option<u32>,
    pub size: Option<Size>,
    pub response_format: Option<Format>,
    pub user: Option<String>,
    pub model: Option<Model>,
}
Expand description

Given a prompt and an instruction, the model will return an edited version of the prompt.

Fields§

§image: Option<(String, Vec<u8>)>§mask: Option<(String, Vec<u8>)>§prompt: Option<String>§n: Option<u32>§size: Option<Size>§response_format: Option<Format>§user: Option<String>§model: Option<Model>

Implementations§

Source§

impl Image

Source

pub fn image(self, filename: &str, bytes: Vec<u8>) -> Self

The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.

§Arguments
  • filename - Image filename to edit or create variant
  • bytes - Image bytes to edit or create variant
Source

pub fn model(self, model: Model) -> Self

Select between DALL·E 3 and DALL·E 2, default DALL·E 2 (if not specified).

§Arguments
  • model - Model to be used
Source

pub fn mask(self, filename: &str, bytes: Vec<u8>) -> Self

An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.

§Arguments
  • filename - Image filename to edit or create variant
  • bytes - Image bytes to edit or create variant
Source

pub fn prompt(self, content: &str) -> Self

A text description of the desired image(s). The maximum length is 1000 characters.

Source

pub fn n(self, n: u32) -> Self

The number of images to generate. Must be between 1 and 10.

Source

pub fn size(self, size: Size) -> Self

The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. Use given enum variant.

Source

pub fn response_format(self, response_format: Format) -> Self

The format in which the generated images are returned. Must be one of url or b64_json.

Source

pub fn user(self, user: &str) -> Self

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

Source

pub async fn editing(&self) -> Result<ImageResponse, Box<dyn Error>>

Send edit request to OpenAI.

Source

pub async fn generation(&mut self) -> Result<ImageResponse, Box<dyn Error>>

Send generation request to OpenAI.

Source

pub async fn variation(&mut self) -> Result<ImageResponse, Box<dyn Error>>

Send variation request to OpenAI.

Trait Implementations§

Source§

impl Debug for Image

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Image

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Image

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Image

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Image

§

impl RefUnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnwindSafe for Image

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T