mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-19 09:50:46 +01:00
fix(builders): fixed part handling,it compiles now
What's missing is docs, which will see some work now. I guess it will be best to hide all the prelude from the user, to allow him to focus on what's important here.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ use std::borrow::BorrowMut;
|
||||
use std::cell::RefCell;
|
||||
use std::default::Default;
|
||||
|
||||
pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestResult, NestedType};
|
||||
pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestValue, NestedType};
|
||||
|
||||
// ########
|
||||
// HUB ###
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
rb_type, mb_type, singular, hub_type, to_fqan, indent_all_but_first_by,
|
||||
method_params, activity_rust_type, mangle_ident, activity_input_type, get_word,
|
||||
split_camelcase_s, property, is_pod_property, TREF, method_io, IO_REQUEST,
|
||||
RESOURCE_MARKER, schema_to_required_property, rust_copy_value_s, is_required_property)
|
||||
schema_to_required_property, rust_copy_value_s, is_required_property)
|
||||
%>\
|
||||
<%namespace name="util" file="util.mako"/>\
|
||||
<%namespace name="lib" file="lib.mako"/>\
|
||||
@@ -18,7 +18,7 @@
|
||||
# an identifier for a property. We prefix them to prevent clashes with the setters
|
||||
ThisType = mb_type(resource, method) + "<'a, C, NC, A>"
|
||||
|
||||
request_resource = method_io(schemas, c, m, IO_REQUEST, RESOURCE_MARKER)
|
||||
request_resource = method_io(schemas, c, m, IO_REQUEST)
|
||||
params = method_params(m)
|
||||
if request_resource:
|
||||
params.insert(0, schema_to_required_property(request_resource, 'request'))
|
||||
@@ -60,9 +60,9 @@ pub struct ${ThisType}
|
||||
% for p in params:
|
||||
${property(p.name)}:\
|
||||
% if is_required_property(p):
|
||||
${activity_rust_type(p, allow_optionals=False)},
|
||||
${activity_rust_type(p, allow_optionals=False)},
|
||||
% else:
|
||||
${activity_rust_type(p)},
|
||||
${activity_rust_type(p)},
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%!
|
||||
from util import (put_and, rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment,
|
||||
rb_type, singular, hub_type, mangle_ident, mb_type, method_params, property,
|
||||
to_fqan, indent_all_but_first_by, RESOURCE_MARKER, schema_markers,
|
||||
to_fqan, indent_all_but_first_by, schema_markers,
|
||||
activity_input_type, TREF, method_io, IO_REQUEST, schema_to_required_property,
|
||||
rust_copy_value_s, is_required_property)
|
||||
%>\
|
||||
@@ -54,7 +54,7 @@ impl<'a, C, NC, A> ${ThisType} {
|
||||
|
||||
# skip part if we have a request resource. Only resources can have parts
|
||||
# that we can easily deduce
|
||||
request_resource = method_io(schemas, c, m, IO_REQUEST, RESOURCE_MARKER)
|
||||
request_resource = method_io(schemas, c, m, IO_REQUEST)
|
||||
params = method_params(m)
|
||||
REQUEST_RESOURCE_PROPERTY_NAME = 'request'
|
||||
if request_resource:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%! from util import (schema_markers, rust_doc_comment, mangle_ident, to_rust_type, put_and,
|
||||
IO_TYPES, activity_split, enclose_in)
|
||||
IO_TYPES, activity_split, enclose_in, REQUEST_MARKER)
|
||||
%>\
|
||||
## Create new schema with everything.
|
||||
## 's' contains the schema structure from json to build
|
||||
@@ -28,8 +28,28 @@ pub struct ${s.id}\
|
||||
impl ${marker_trait} for ${s.id} {}
|
||||
% endfor
|
||||
|
||||
% if RESOURCE_MARKER in markers:
|
||||
|
||||
% if REQUEST_MARKER in markers:
|
||||
impl ${s.id} {
|
||||
/// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`.
|
||||
/// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or
|
||||
/// the parts you want to see in the server response.
|
||||
fn to_parts(&self) -> String {
|
||||
let mut r = String::new();
|
||||
% for pn, p in s.properties.iteritems():
|
||||
<%
|
||||
mn = 'self.' + mangle_ident(pn)
|
||||
rt = to_rust_type(s.id, pn, p)
|
||||
check = 'is_some()'
|
||||
if rt.startswith('Vec') or rt.startswith('HashMap'):
|
||||
check = 'len() > 0'
|
||||
%>\
|
||||
if ${mn}.${check} { r = r + "${pn},"; }
|
||||
% endfor
|
||||
## remove (possibly non-existing) trailing comma
|
||||
r.pop();
|
||||
r
|
||||
}
|
||||
}
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ SPACES_PER_TAB = 4
|
||||
|
||||
REQUEST_PRIORITY = 100
|
||||
REQUEST_MARKER = 'RequestValue'
|
||||
RESOURCE_MARKER = 'Resource'
|
||||
|
||||
# ==============================================================================
|
||||
## @name Filters
|
||||
@@ -256,7 +255,7 @@ def schema_markers(s, c):
|
||||
# it should have at least one activity that matches it's type to qualify for the Resource trait
|
||||
for fqan, iot in activities.iteritems():
|
||||
if activity_name_to_type_name(activity_split(fqan)[0]).lower() == s.id.lower():
|
||||
res.add(RESOURCE_MARKER)
|
||||
res.add('Resource')
|
||||
if IO_RESPONSE in iot:
|
||||
res.add('ResponseResult')
|
||||
if IO_REQUEST in iot:
|
||||
|
||||
Reference in New Issue
Block a user