Crates.io | dagpirs |
lib.rs | dagpirs |
version | 0.1.7 |
source | src |
created_at | 2021-03-15 15:59:17.04714 |
updated_at | 2021-08-02 14:11:02.656037 |
description | A pure rust wrapper for dagpi, with image manipulation and data fetching. |
homepage | https://dagpi.xyz |
repository | https://github.com/daggy1234/dagpirs |
max_upload_size | |
id | 369268 |
size | 47,741 |
A pure rust wrapper for dagpi.
Crate: link
Docs: link
Discord: link
Please Note this was inspired by Ksoft.rs. License
[dependencies]
version="1.0.0"
[dependencies.tokio]
version = "1.0"
features = ["macros"]
Uses a very basic Data Endpoint to fetch data from the api.
use dagpi::Client;
#[tokio::main]
async fn main() {
let client =
Client::new("TOKEN").unwrap();
match client.data.fact().await.unwrap() {
Ok(f) => println!("{}", f.fact),
Err(e) => println!("{:?}", e),
};
}
Uses the image client ot process and save an image to file based on it;s format!
use dagpi::Client;
#[tokio::main]
async fn main() {
let client =
Client::new("TOKEN").unwrap();
match client.image.image_proess("https://cdn.discordapp.com/avatars/716323270982631476/fa9fed1ed0d51eb4a15b654f3ae08215.png".to_string(), dagpi::models::ImageManipulation::Wanted).await.unwrap() {
Ok(v) => {
let buff: Bytes = v.bytes;
let mut f = fs::File::create(format!("memes.{}", v.format)).unwrap();
f.write_all(buff.to_vec().as_slice()).unwrap();
}
Err(s) => println!("{}", s),
};
}
use dagpi::Client;
#[tokio::main]
async fn main() {
let client =
Client::new("").unwrap();
match client.data.fact().await.unwrap() {
Ok(f) => println!("{}", f.fact),
Err(e) => println!("{:?}", e),
};
match client.image.yt("https://cdn.discordapp.com/avatars/716323270982631476/fa9fed1ed0d51eb4a15b654f3ae08215.png".to_string(), "daggy", "Tweeting using dagpi.xyz is so much fun!. Goes great with dagpi.rs", false).await.unwrap() {
Ok(v) => {
let buff: Bytes = v.bytes;
let mut f = fs::File::create(format!("discord.{}", v.format)).unwrap();
f.write_all(buff.to_vec().as_slice()).unwrap();
}
Err(s) => println!("{}", s),
};
}
Basic blocking usecase.
[dependencies.dagpirs]
version="1.0.0"
default-features=false
features = ["blocking"]
Uses a very basic Data Endpoint to fetch data from the api.
use dagpi::Client;
fn main() {
let client =
Client::new("TOKEN").unwrap();
match client.data.roast().unwrap() {
Ok(f) => println!("{}", f.roast),
Err(e) => println!("{:?}", e),
};
}
Uses the image client ot process and save an image to file based on it;s format!
use dagpi::Client;
fn main() {
let client =
Client::new("TOKEN").unwrap();
match client.image.image_proess("https://cdn.discordapp.com/avatars/716323270982631476/fa9fed1ed0d51eb4a15b654f3ae08215.png".to_string(), dagpi::models::ImageManipulation::Wasted).unwrap() {
Ok(v) => {
let buff: Bytes = v.bytes;
let mut f = fs::File::create(format!("memes.{}", v.format)).unwrap();
f.write_all(buff.to_vec().as_slice()).unwrap();
}
Err(s) => println!("{}", s),
};
}
use dagpi::Client;
fn main() {
let client =
Client::new("").unwrap();
match client.image.pride("https://cdn.discordapp.com/avatars/716323270982631476/fa9fed1ed0d51eb4a15b654f3ae08215.png".to_string(), dagpi::models::Pride::Bisexual).unwrap() {
Ok(v) => {
let buff: Bytes = v.bytes;
let mut f = fs::File::create(format!("discord.{}", v.format)).unwrap();
f.write_all(buff.to_vec().as_slice()).unwrap();
}
Err(s) => println!("{}", s),
};
}
Docs for more examples.
Or the Examples folder in the repo.