Function create_private_paste_async

Source
pub async fn create_private_paste_async(
    contents: CreateObject,
    auth_token: &str,
) -> Result<PasteObject, Error>
Expand description

Uses the CreateObject struct and a &str authorization key as a parameter which you can get from user settings on pastemyst. This data is constructed into json format and sent to pastemyst in an asynchronous manner. The paste is send under the ownership of the account the auth key belongs to.

ยงExamples

use pastemyst::paste::*;
 
fn main() -> Result<(), reqwest::Error> /*PasteResult<()>*/ {
    let pasties: Vec<PastyObject> = vec![
        PastyObject {
            _id: None,
            language: Some(String::from("autodetect")),
            title: Some(String::from("A pasty title")),
            code: Some(String::from("fn main() { println!(\"Hello World!\"); }")),
        },
        PastyObject {
            _id: None,
            title: Some(String::from("Another pasty title")),
            language: Some(String::from("autodetect")),
            code: Some(String::from(
                "#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}",
            )),
        },
    ];
    let data: CreateObject = CreateObject {
        title: String::from("[crates.io/crates/pastemyst] This is a title"),
        expiresIn: String::from("1d"),
        isPrivate: false,
        isPublic: false,
        tags: String::from(""),
        pasties,
    };
    let paste = create_private_paste(
        data,
        "Your PasteMyst Token. Get it from: https://paste.myst.rs/user/settings",
    )?;
    println!("{:#?}", paste.ownerId);
    Ok(())
}