Function pastemyst::paste::create_paste [−][src]
pub fn create_paste(contents: CreateObject) -> Result<PasteObject, Error>
Uses the CreateObject
struct as a parameter for paste
data to be constructed into json format and sent to
pastemyst in a synchronous manner.
Examples
use pastemyst::paste::PastyObject; use pastemyst::paste::*; fn main() -> PasteResult<()> { let pasties: Vec<PastyObject> = vec![ PastyObject { _id: None, language: Some(String::from("autodetect")), title: Some(String::from("Pasty1")), code: Some(String::from("Code")), }, PastyObject { _id: None, language: Some(String::from("autodetect")), title: Some(String::from("Pasty2")), code: Some(String::from("Code")), }, ]; 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: pasties, }; let paste = create_paste(data)?; println!("{:#?}", paste._id); Ok(()) }