mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-02 17:42:16 +01:00
fix(doit): remove BorrowMut until it's cleared
See stackoverflow at http://goo.gl/f27zJkj. Now we can actually call out client and move on with handling the result
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<%
|
||||
from util import (new_context, rust_comment, rust_doc_comment,
|
||||
rust_module_doc_comment, rb_type, hub_type, mangle_ident, hub_type_params_s,
|
||||
hub_type_bounds, rb_type_params_s, find_fattest_resource)
|
||||
hub_type_bounds, rb_type_params_s, find_fattest_resource, HUB_TYPE_PARAMETERS)
|
||||
|
||||
c = new_context(schemas, resources)
|
||||
hub_type = hub_type(c.schemas, util.canonical_name())
|
||||
@@ -19,9 +19,9 @@
|
||||
<%block filter="rust_module_doc_comment">\
|
||||
${lib.docs(c)}
|
||||
</%block>
|
||||
#![feature(core,io)]
|
||||
#![feature(core,io, old_io)]
|
||||
// DEBUG !! TODO: Remove this
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, deprecated)]
|
||||
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
||||
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
||||
// unused imports in fully featured APIs. Same with unused_mut ... .
|
||||
@@ -37,8 +37,6 @@ extern crate url;
|
||||
pub mod cmn;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::cell::RefCell;
|
||||
use std::default::Default;
|
||||
use std::collections::BTreeMap;
|
||||
@@ -84,21 +82,19 @@ ${lib.scope_enum()}
|
||||
${lib.hub_usage_example(c)}\
|
||||
</%block>
|
||||
pub struct ${hub_type}${ht_params} {
|
||||
client: RefCell<C>,
|
||||
client: RefCell<hyper::Client<NC>>,
|
||||
auth: RefCell<A>,
|
||||
_m: PhantomData<NC>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> Hub for ${hub_type}${ht_params} {}
|
||||
impl<'a, ${', '.join(HUB_TYPE_PARAMETERS)}> Hub for ${hub_type}${ht_params} {}
|
||||
|
||||
impl<'a, C, NC, A> ${hub_type}${ht_params}
|
||||
impl<'a, ${', '.join(HUB_TYPE_PARAMETERS)}> ${hub_type}${ht_params}
|
||||
where ${', '.join(hub_type_bounds())} {
|
||||
|
||||
pub fn new(client: C, authenticator: A) -> ${hub_type}${ht_params} {
|
||||
pub fn new(client: hyper::Client<NC>, authenticator: A) -> ${hub_type}${ht_params} {
|
||||
${hub_type} {
|
||||
client: RefCell::new(client),
|
||||
auth: RefCell::new(authenticator),
|
||||
_m: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ ${self.usage(resource, method, m, params, request_value, parts)}\
|
||||
</%block>
|
||||
pub struct ${ThisType}
|
||||
where NC: 'a,
|
||||
C: 'a,
|
||||
A: 'a, {
|
||||
|
||||
hub: &'a ${hub_type_name}${hub_type_params_s()},
|
||||
@@ -430,7 +429,7 @@ else {
|
||||
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
||||
|
||||
loop {
|
||||
match self.hub.client.borrow_mut().borrow_mut().request(Method::Extension("${m.httpMethod}".to_string()), &url)
|
||||
match self.hub.client.borrow_mut().request(Method::Extension("${m.httpMethod}".to_string()), url.as_slice())
|
||||
.header(UserAgent("google-api-rust-client/${cargo.build_version}".to_string()))
|
||||
% if request_value:
|
||||
.header(ContentType(Mime(TopLevel::Application, SubLevel::Json, Default::default())))
|
||||
@@ -457,33 +456,12 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
% if response_schema:
|
||||
let response: ${response_schema.id} = Default::default();
|
||||
% else:
|
||||
let response = ();
|
||||
% endif
|
||||
|
||||
|
||||
## let mut params: Vec<(String, String)> = Vec::with_capacity
|
||||
## // note: cloned() shouldn't be needed, see issue
|
||||
## // https://github.com/servo/rust-url/issues/81
|
||||
## let req = form_urlencoded::serialize(
|
||||
## [("client_id", client_id),
|
||||
## ("scope", scopes.into_iter()
|
||||
## .map(|s| s.as_slice())
|
||||
## .intersperse(" ")
|
||||
## .collect::<String>()
|
||||
## .as_slice())].iter().cloned());
|
||||
|
||||
## match self.client.borrow_mut().post(FlowType::Device.as_slice())
|
||||
## .header(ContentType("application/x-www-form-urlencoded".parse().unwrap()))
|
||||
## .body(req.as_slice())
|
||||
## .send() {
|
||||
## Err(err) => {
|
||||
## return RequestResult::Error(err);
|
||||
## }
|
||||
|
||||
cmn::Result::Success(response)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ let rb = hub.${mangle_ident(resource)}();
|
||||
</%block>
|
||||
pub struct ${ThisType}
|
||||
where NC: 'a,
|
||||
C: 'a,
|
||||
A: 'a, {
|
||||
|
||||
hub: &'a ${hub_type_name}${hub_type_params_s()},
|
||||
|
||||
@@ -98,7 +98,7 @@ data_unit_multipliers = {
|
||||
'%': 1,
|
||||
}
|
||||
|
||||
HUB_TYPE_PARAMETERS = ('C', 'NC', 'A')
|
||||
HUB_TYPE_PARAMETERS = ('NC', 'A')
|
||||
|
||||
# ==============================================================================
|
||||
## @name Filters
|
||||
@@ -732,7 +732,6 @@ def hub_type_params_s():
|
||||
# return a list of where statements to server as bounds for the hub.
|
||||
def hub_type_bounds():
|
||||
return ['NC: hyper::net::NetworkConnector',
|
||||
"C: BorrowMut<hyper::Client<NC>> + 'a",
|
||||
'A: oauth2::GetToken']
|
||||
|
||||
# return list of type bounds required by method builder
|
||||
|
||||
Reference in New Issue
Block a user