From cfb8faefb8545114ddadea59871214b35e515d5a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 20 Mar 2015 14:47:26 +0100 Subject: [PATCH] fix(json): Vec/HashMap are Optionals That assures that we can decode partial server responses, and send partial structures as well. --- src/mako/lib/mbuild.mako | 2 +- src/mako/lib/util.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mako/lib/mbuild.mako b/src/mako/lib/mbuild.mako index 929dd7a286..19a4dd9c8d 100644 --- a/src/mako/lib/mbuild.mako +++ b/src/mako/lib/mbuild.mako @@ -649,7 +649,7 @@ else { % if request_value: let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self.${property(REQUEST_VALUE_PROPERTY_NAME)}).unwrap()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self.${property(REQUEST_VALUE_PROPERTY_NAME)})); let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); % endif diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index ef2c9b288f..a2d5f5ac1a 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -320,10 +320,10 @@ def to_rust_type(schemas, sn, pn, t, allow_optionals=True): try: rust_type = TYPE_MAP[t.type] if t.type == 'array': - return "%s<%s>" % (rust_type, unique_type_name((nested_type(t)))) + return wrap_type("%s<%s>" % (rust_type, unique_type_name((nested_type(t))))) elif t.type == 'object': if _is_map_prop(t): - return "%s" % (rust_type, nested_type(t)) + return wrap_type("%s" % (rust_type, nested_type(t))) else: return wrap_type(nested_type(t)) elif t.type == 'string' and 'Count' in pn: