Created
March 7, 2018 16:31
-
-
Save anna-is-cute/db1f7e80e98f32538dee2ae23b60bdf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut core = Core::new().unwrap(); | |
let client = Arc::new(Client::configure() | |
.connector(HttpsConnector::new(4, &core.handle()).unwrap()) | |
.build(&core.handle())); | |
let pending = vec![ | |
PendingPasteFile { | |
content: String::from("this is a test"), | |
metadata: RequestedMetadata::default() | |
}, | |
PendingPasteFile { | |
content: String::from("and another test"), | |
metadata: RequestedMetadata::default() | |
} | |
]; | |
let hastebin = Hastebin::new(client); | |
let url = Url::parse("https://hastebin.com/qiwigalure.bash").unwrap(); | |
let id = Hastebin::extract_id(&url).unwrap(); | |
let task = hastebin.fetch(&id).unwrap(); | |
println!("fetch"); | |
println!("{:#?}", core.run(task.collect())); | |
println!(); | |
let task = hastebin.store(pending).unwrap(); | |
println!("store"); | |
println!("{:#?}", core.run(task.collect())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch | |
Ok( | |
[ | |
PasteFile { | |
id: "qiwigalure", | |
content: Full( | |
"test" | |
), | |
urls: Urls { | |
html: "https://hastebin.com/qiwigalure", | |
raw: "https://hastebin.com/raw/qiwigalure" | |
}, | |
metadata: Metadata { | |
public: None, | |
author: None | |
} | |
} | |
] | |
) | |
store | |
Ok( | |
[ | |
PasteFile { | |
id: "xujoludebi", | |
content: NotIncluded, | |
urls: Urls { | |
html: "https://hastebin.com/xujoludebi", | |
raw: "https://hastebin.com/raw/xujoludebi" | |
}, | |
metadata: Metadata { | |
public: None, | |
author: None | |
} | |
}, | |
PasteFile { | |
id: "ponucabino", | |
content: NotIncluded, | |
urls: Urls { | |
html: "https://hastebin.com/ponucabino", | |
raw: "https://hastebin.com/raw/ponucabino" | |
}, | |
metadata: Metadata { | |
public: None, | |
author: None | |
} | |
} | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment