fix(json): Vec/HashMap are Optionals

That assures that we can decode partial server responses, and send
partial structures as well.
This commit is contained in:
Sebastian Thiel
2015-03-20 14:47:26 +01:00
parent 9f719dd928
commit cfb8faefb8
2 changed files with 3 additions and 3 deletions

View File

@@ -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

View File

@@ -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<String, %s>" % (rust_type, nested_type(t))
return wrap_type("%s<String, %s>" % (rust_type, nested_type(t)))
else:
return wrap_type(nested_type(t))
elif t.type == 'string' and 'Count' in pn: