Struct dagpirs::image::Image[][src]

pub struct Image { /* fields omitted */ }

Image Manipulation Functions for async client.

Implementations

impl Image[src]

pub fn new(http: Arc<Client>) -> Self[src]

pub async fn image_process(
    &self,
    url: String,
    manipulation: ImageManipulation
) -> HttpResult<ImageResponse, String>
[src]

Sample Image Processing This example processes a URL and saves a format aware Image

Example

use dagpirs::{Client, Bytes};
// Only here the std fs is used, in prod for async use the tokio::fs;
use std::fs;
use std::io::Write;
use tokio;
#[tokio::main]
async fn main() {
    let token = std::env::var("DAGPI_TOKEN").unwrap();
    let c = Client::new(&token).unwrap();
    if let Ok(i) = c.image.image_process("https://dagpi.xyz/dagpi.png".to_string(), dagpirs::models::ImageManipulation::Wanted).await {
        match i {
            Ok(im) => {
                let buff: Bytes = im.bytes;
                let mut f = fs::File::create(format!("wanted.{}", im.format)).unwrap();
                f.write_all(buff.to_vec().as_slice()).unwrap();
        },
            Err(e) => panic!("{}", e)    
        }
    }
}

pub async fn image_process_text(
    &self,
    url: String,
    text: String,
    manipulation: ImageManipulationText
) -> HttpResult<ImageResponse, String>
[src]

Process an image with text

pub async fn image_process_top_bottom(
    &self,
    url: String,
    top_text: String,
    bottom_text: String,
    manipulation: ImageManipulationTopBottom
) -> HttpResult<ImageResponse, String>
[src]

Process and Image with both top and bottom text

pub async fn tweet(
    &self,
    url: String,
    username: String,
    text: String
) -> HttpResult<ImageResponse, String>
[src]

Generate a realistic fake tweet

pub async fn yt(
    &self,
    url: String,
    username: String,
    text: String,
    dark: bool
) -> HttpResult<ImageResponse, String>
[src]

Generate a realistic fake youtube comment

pub async fn discord_message(
    &self,
    url: String,
    username: String,
    text: String,
    dark: bool
) -> HttpResult<ImageResponse, String>
[src]

Generate a realistic fake discord message

pub async fn pride(
    &self,
    url: String,
    flag: Pride
) -> HttpResult<ImageResponse, String>
[src]

Put a pride flag overlay over an image from a selection of pride flags

Auto Trait Implementations

impl !RefUnwindSafe for Image

impl Send for Image

impl Sync for Image

impl Unpin for Image

impl !UnwindSafe for Image

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> WithSubscriber for T[src]