mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
fix(rustup): rustc (be9bd7c93 2015-04-05)
* using std::convert * update to latest hyper (and other dependencies) Related to #46
This commit is contained in:
@@ -22,20 +22,20 @@
|
||||
<%block filter="rust_module_doc_comment">\
|
||||
${lib.docs(c)}
|
||||
</%block>
|
||||
#![feature(core,io,thread_sleep)]
|
||||
#![feature(std_misc)]
|
||||
// Unused attributes happen thanks to defined, but unused structures
|
||||
// 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 ... .
|
||||
#![allow(unused_imports, unused_mut, dead_code)]
|
||||
// Required for serde annotations
|
||||
#![feature(custom_derive, custom_attribute, plugin)]
|
||||
#![feature(custom_derive, custom_attribute, plugin, slice_patterns)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate hyper;
|
||||
extern crate serde;
|
||||
extern crate "yup-oauth2" as oauth2;
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate mime;
|
||||
extern crate url;
|
||||
|
||||
@@ -50,7 +50,7 @@ use std::marker::PhantomData;
|
||||
use serde::json;
|
||||
use std::io;
|
||||
use std::fs;
|
||||
use std::thread::sleep;
|
||||
use std::thread::sleep_ms;
|
||||
|
||||
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
# end for each method
|
||||
header_methods = (('Upload', upload_methods), ('Download', download_methods), ('Subscription', subscription_methods))
|
||||
%>\
|
||||
This documentation was generated from *${util.canonical_name()}* crate version *${util.crate_version()}*, where *${revision}* is the exact revision of the *${id}* schema built by the [mako](http://www.makotemplates.org/) code generator *v${cargo.build_version}*.
|
||||
This documentation was generated from *${util.canonical_name()}* crate version *${util.crate_version()}*, where *${revision is UNDEFINED and '00000000' or revision}* is the exact revision of the *${id}* schema built by the [mako](http://www.makotemplates.org/) code generator *v${cargo.build_version}*.
|
||||
% if documentationLink:
|
||||
|
||||
Everything else about the *${util.canonical_name()}* *${api_version}* API can be found at the
|
||||
@@ -340,8 +340,8 @@ pub enum Scope {
|
||||
% endfor
|
||||
}
|
||||
|
||||
impl Str for Scope {
|
||||
fn as_slice(&self) -> &str {
|
||||
impl AsRef<str> for Scope {
|
||||
fn as_ref(&self) -> &str {
|
||||
match *self {
|
||||
% for url in auth.oauth2.scopes.keys():
|
||||
${scope_url_to_variant(name, url)} => "${url}",
|
||||
|
||||
@@ -151,8 +151,8 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
% endfor
|
||||
% endif
|
||||
pub fn ${ADD_PARAM_FN}<T>(mut self, name: T, value: T) -> ${ThisType}
|
||||
where T: Str {
|
||||
self.${api.properties.params}.insert(name.as_slice().to_string(), value.as_slice().to_string());
|
||||
where T: AsRef<str> {
|
||||
self.${api.properties.params}.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -169,8 +169,8 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||||
/// sufficient, a read-write scope will do as well.
|
||||
pub fn add_scope<T>(mut self, scope: T) -> ${ThisType}
|
||||
where T: Str {
|
||||
self.${api.properties.scopes}.insert(scope.as_slice().to_string(), ());
|
||||
where T: AsRef<str> {
|
||||
self.${api.properties.scopes}.insert(scope.as_ref().to_string(), ());
|
||||
self
|
||||
}
|
||||
% endif
|
||||
@@ -544,7 +544,7 @@ match result {
|
||||
for &(name, ref value) in params.iter() {
|
||||
if name == "alt" {
|
||||
field_present = false;
|
||||
if value.as_slice() != "json" {
|
||||
if <String as AsRef<str>>::as_ref(&value) != "json" {
|
||||
enable = false;
|
||||
}
|
||||
break;
|
||||
@@ -596,7 +596,7 @@ else {
|
||||
}
|
||||
% else:
|
||||
if self.${api.properties.scopes}.len() == 0 {
|
||||
self.${api.properties.scopes}.insert(${scope_url_to_variant(name, default_scope, fully_qualified=True)}.as_slice().to_string(), ());
|
||||
self.${api.properties.scopes}.insert(${scope_url_to_variant(name, default_scope, fully_qualified=True)}.as_ref().to_string(), ());
|
||||
}
|
||||
% endif
|
||||
|
||||
@@ -646,7 +646,7 @@ else {
|
||||
|
||||
if params.len() > 0 {
|
||||
url.push('?');
|
||||
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
||||
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
||||
}
|
||||
|
||||
% if request_value:
|
||||
@@ -710,7 +710,7 @@ else {
|
||||
};
|
||||
% endif
|
||||
let mut client = &mut *self.hub.client.borrow_mut();
|
||||
let mut req = client.borrow_mut().request(${method_name_to_variant(m.httpMethod)}, url.as_slice())
|
||||
let mut req = client.borrow_mut().request(${method_name_to_variant(m.httpMethod)}, url.as_ref())
|
||||
.header(UserAgent(self.hub._user_agent.clone()))\
|
||||
% if supports_scopes(auth):
|
||||
|
||||
@@ -755,7 +755,7 @@ else {
|
||||
match req_result {
|
||||
Err(err) => {
|
||||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||||
sleep(d);
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
continue;
|
||||
}
|
||||
${delegate_finish}(false);
|
||||
@@ -766,7 +766,7 @@ else {
|
||||
let mut json_err = String::new();
|
||||
res.read_to_string(&mut json_err).unwrap();
|
||||
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
||||
sleep(d);
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
continue;
|
||||
}
|
||||
${delegate_finish}(false);
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
if make.documentation_engine == 'mkdocs':
|
||||
return gen_root + '/' + mkdocs.site_dir
|
||||
else:
|
||||
return gen_root + '/target/doc/' + crate_name
|
||||
return gen_root + '/target/doc/' + util.to_extern_crate_name(crate_name)
|
||||
# end utility
|
||||
|
||||
central_api_index = lambda crate_name: doc_root + '/' + crate_name + '/index.html'
|
||||
central_api_index = lambda crate_name: doc_root + '/' + util.to_extern_crate_name(crate_name) + '/index.html'
|
||||
|
||||
discovery_url = 'https://www.googleapis.com/discovery/v1/'
|
||||
apis = json.loads(urllib2.urlopen(discovery_url + "apis").read())
|
||||
@@ -27,6 +27,12 @@
|
||||
suffix = make.target_suffix
|
||||
agsuffix = make.aggregated_target_suffix
|
||||
global_targets = make.get('global_targets', False)
|
||||
|
||||
try:
|
||||
root = directories.mako_src + '/' + make.id + '/lib'
|
||||
lib_files = [os.path.join(root, file_name) for file_name in os.listdir(root)]
|
||||
except OSError:
|
||||
lib_files = list()
|
||||
%>\
|
||||
% for an, versions in api.list.iteritems():
|
||||
% if an in api.get('blacklist', list()):
|
||||
@@ -60,7 +66,7 @@
|
||||
api_json = directories.api_base + '/' + an + '/' + version + '/' + an + '-api.json'
|
||||
api_meta_dir = os.path.dirname(api_json)
|
||||
api_crate_publish_file = api_meta_dir + '/crates/' + util.crate_version(cargo.build_version + make.aggregated_target_suffix,
|
||||
json.load(open(api_json, 'r'))['revision'])
|
||||
json.load(open(api_json, 'r')).get('revision', '00000000'))
|
||||
api_json_overrides = api_meta_dir + '/' + an + '-api_overrides.json'
|
||||
type_specific_json = '$(API_DIR)/type-' + make.id + '.yaml'
|
||||
api_json_inputs = api_json + ' $(API_SHARED_INFO) ' + type_specific_json
|
||||
@@ -75,7 +81,7 @@ ${api_common}: $(RUST_SRC)/${make.id}/cmn.rs $(lastword $(MAKEFILE_LIST)) ${gen_
|
||||
@ echo "// DO NOT EDIT" >> $@
|
||||
@cat $< >> $@
|
||||
|
||||
${gen_root_stamp}: ${' '.join(i[0] for i in sds)} ${api_json_inputs} $(MAKO_STANDARD_DEPENDENCIES) ${depends_on_target}
|
||||
${gen_root_stamp}: ${' '.join(i[0] for i in sds)} ${' '.join(lib_files)} ${api_json_inputs} $(MAKO_STANDARD_DEPENDENCIES) ${depends_on_target}
|
||||
@echo Generating ${api_target}
|
||||
@$(MAKO) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs}
|
||||
@touch $@
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<%
|
||||
import os
|
||||
from util import (library_name, library_to_crate_name)
|
||||
from util import (library_name, library_to_crate_name, to_extern_crate_name)
|
||||
|
||||
def api_index(name, version):
|
||||
index_file_path = library_to_crate_name(library_name(name, version), make.target_suffix) + '/index.html'
|
||||
index_file_path = to_extern_crate_name(library_to_crate_name(library_name(name, version), make.target_suffix)) + '/index.html'
|
||||
if os.path.isfile(DOC_ROOT + '/' + index_file_path):
|
||||
return index_file_path
|
||||
return None
|
||||
|
||||
@@ -28,15 +28,15 @@ ${util.library_to_crate_name(util.library_name(name, version), make.target_suffi
|
||||
</%def>
|
||||
|
||||
<%def name="crate_version()" buffered="True">\
|
||||
${util.crate_version(cargo.build_version, revision)}\
|
||||
${util.crate_version(cargo.build_version, revision is UNDEFINED and '00000000' or revision)}\
|
||||
</%def>
|
||||
|
||||
## All crates and standard `use` declaration, required for all examples
|
||||
## Must be outside of a test function
|
||||
<%def name="test_prelude()">\
|
||||
extern crate hyper;
|
||||
extern crate "yup-oauth2" as oauth2;
|
||||
extern crate "${self.crate_name()}" as ${self.library_name()};
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate ${util.to_extern_crate_name(self.crate_name())} as ${self.library_name()};
|
||||
</%def>
|
||||
|
||||
## Define the canonical name, if present, or name otherwise
|
||||
|
||||
@@ -810,6 +810,10 @@ def library_to_crate_name(name, suffix=''):
|
||||
def crate_version(build_version, revision):
|
||||
return '%s+%s' % (build_version, revision)
|
||||
|
||||
# return a crate name for us in extern crate statements
|
||||
def to_extern_crate_name(crate_name):
|
||||
return crate_name.replace('-', '_')
|
||||
|
||||
# return type name of a resource method builder, from a resource name
|
||||
def rb_type(r):
|
||||
return "%sMethods" % singular(canonical_type_name(r))
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use std::marker::MarkerTrait;
|
||||
use std::io::{self, Read, Seek, Cursor, Write, SeekFrom};
|
||||
use std;
|
||||
use std::fmt::{self, Display};
|
||||
use std::str::FromStr;
|
||||
use std::thread::sleep;
|
||||
use std::thread::sleep_ms;
|
||||
|
||||
use mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
||||
use oauth2::{TokenType, Retry, self};
|
||||
@@ -19,35 +18,35 @@ use serde;
|
||||
/// Identifies the Hub. There is only one per library, this trait is supposed
|
||||
/// to make intended use more explicit.
|
||||
/// The hub allows to access all resource methods more easily.
|
||||
pub trait Hub: MarkerTrait {}
|
||||
pub trait Hub {}
|
||||
|
||||
/// Identifies types for building methods of a particular resource type
|
||||
pub trait MethodsBuilder: MarkerTrait {}
|
||||
pub trait MethodsBuilder {}
|
||||
|
||||
/// Identifies types which represent builders for a particular resource method
|
||||
pub trait CallBuilder: MarkerTrait {}
|
||||
pub trait CallBuilder {}
|
||||
|
||||
/// Identifies types which can be inserted and deleted.
|
||||
/// Types with this trait are most commonly used by clients of this API.
|
||||
pub trait Resource: MarkerTrait {}
|
||||
pub trait Resource {}
|
||||
|
||||
/// Identifies types which are used in API responses.
|
||||
pub trait ResponseResult: MarkerTrait {}
|
||||
pub trait ResponseResult {}
|
||||
|
||||
/// Identifies types which are used in API requests.
|
||||
pub trait RequestValue: MarkerTrait {}
|
||||
pub trait RequestValue {}
|
||||
|
||||
/// Identifies types which are not actually used by the API
|
||||
/// This might be a bug within the google API schema.
|
||||
pub trait UnusedType: MarkerTrait {}
|
||||
pub trait UnusedType {}
|
||||
|
||||
/// Identifies types which are only used as part of other types, which
|
||||
/// usually are carrying the `Resource` trait.
|
||||
pub trait Part: MarkerTrait {}
|
||||
pub trait Part {}
|
||||
|
||||
/// Identifies types which are only used by other types internally.
|
||||
/// They have no special meaning, this trait just marks them for completeness.
|
||||
pub trait NestedType: MarkerTrait {}
|
||||
pub trait NestedType {}
|
||||
|
||||
/// A utility to specify reader types which provide seeking capabilities too
|
||||
pub trait ReadSeek: Seek + Read {}
|
||||
@@ -378,14 +377,10 @@ impl<'a> Read for MultiPartReader<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// The `X-Upload-Content-Type` header.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct XUploadContentType(pub Mime);
|
||||
|
||||
impl_header!(XUploadContentType,
|
||||
"X-Upload-Content-Type",
|
||||
Mime);
|
||||
header!{
|
||||
#[doc="The `X-Upload-Content-Type` header."]
|
||||
(XUploadContentType, "X-Upload-Content-Type") => [Mime]
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Chunk {
|
||||
@@ -517,7 +512,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
Some(hh) if r.status == StatusCode::PermanentRedirect => hh,
|
||||
None|Some(_) => {
|
||||
if let Retry::After(d) = self.delegate.http_failure(&r, None) {
|
||||
sleep(d);
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
continue;
|
||||
}
|
||||
return Err(Ok(r))
|
||||
@@ -527,7 +522,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
}
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
continue;
|
||||
}
|
||||
return Err(Err(err))
|
||||
@@ -584,7 +579,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
let mut json_err = String::new();
|
||||
res.read_to_string(&mut json_err).unwrap();
|
||||
if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) {
|
||||
sleep(d);
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -592,7 +587,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
},
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
continue;
|
||||
}
|
||||
return Some(Err(err))
|
||||
|
||||
Reference in New Issue
Block a user