# A rich and hybrid mystb.in API wrapper for Rust 🦀

crates.io Documentation MIT

## Introduction

myust is a rich and hybrid Rust wrapper for the mystb.in API that aims for user-flexibility.

myust supports hybrid clients:

To use AuthClient, you must have a mystb.in API token to authenticate you to the API. Log into mystb.in to get your own API token.

## Installation

Add myust = "1.0" to your Cargo.toml file.

toml [dependencies] myust = "1.0" tokio = "1.27.0"

If you want to use synchronous clients, add the sync feature.

toml [dependencies] myust = { version = "0.1", features = ["sync"] }

## Usage Examples

Asynchronously creating a paste with tomorrow expiration date, with error handling: ```rust use chrono::{Days, Utc}; use myust::Client;

[tokio::main]

async fn main() { let client = Client::new(); let tomorrow = Utc::now().checkedadddays(Days::new(1)).unwrap().into(); let result = client .createpaste(|p| { p.filename("myust.txt") .content("Hello from myust!") .expires(tomorrow) }) .await; match result { Ok() => { let paste = result.unwrap(); let url = format!("https://mystb.in/{}", paste.id); println!("Result: {}", url) }, Err() => { println!("Error code: {}", result.unwraperr().code) } } } Synchronously creating a multifile paste with a password (you must have the `sync` feature enabled): rust use myust::SyncClient;

fn main() { let client = SyncClient::new(); let paste = client .createmultifilepaste(|p| { p.file(|f| { f.filename("myust1.txt") .content("first file") .password("myust") }); // set the password on the first file only, same for expiration date p.file(|f| f.filename("myust2.txt").content("second file")) }) .unwrap(); let url = format!("https://mystb.in/{}", paste.id); println!("Result: {}", url) } ```

Asynchronously deleting a paste (you must own the paste): ```rust use myust::AuthClient;

[tokio::main]

async fn main() { let client = AuthClient::new("YOURMYSTBINTOKEN").await; let result = client.deletepaste("EquipmentMovingExpensive").await; // The paste ID to delete match result { Ok() => println!("Successfully deleted the paste."), Err() => { println!("Error code: {}", result.unwraperr().code) } } } ```

You can check for another example snippets in the test file.

Help & Contributing

If you need any help regarding myust, feel free to open an issue about your problem, and feel free to make a pull request for bugfix, code improvements, etc.