Euan Kemp 2e6bec7345 [Rust] Split out request logic, implement form parameters (#528)
* [Rust] Move request logic into standalone file

This reduces the number of variables which are used in the generated
operations, thus fixing #512.

This also fixed a TODO related to URI parsing errors.
Other than that, it is meant to be functionally identical.

* [Rust] Add support for non-file form params

Up until now, they just weren't there at all

* [Rust] Use more rustic terms in example
2018-07-23 23:10:53 +08:00

40 lines
1.1 KiB
Rust

extern crate futures;
extern crate hyper;
extern crate petstore_client;
extern crate tokio_core;
use futures::Future;
use hyper::client::HttpConnector;
use hyper::Client;
use tokio_core::reactor::Core;
fn main() {
let mut core = Core::new().expect("failed to init core");
let handle = core.handle();
let apicli = petstore_client::apis::client::APIClient::new(
petstore_client::apis::configuration::Configuration::new(
Client::configure()
.connector(HttpConnector::new(4, &handle))
.build(&handle),
),
);
let new_pet = petstore_client::models::Pet::new("ferris".to_owned(), vec![]).with_id(128149);
let work = apicli
.pet_api()
.add_pet(new_pet)
.and_then(|_| {
apicli
.pet_api()
.update_pet_with_form(128149, "ferris", "rusted")
})
.and_then(|_| apicli.pet_api().get_pet_by_id(128149))
.and_then(|pet| {
println!("pet: {:?}", pet);
futures::future::ok(())
});
core.run(work).expect("failed to run core");
}