Chromium Code Reviews| Index: mojo/public/rust/tests/util/mojom_validation.rs |
| diff --git a/mojo/public/rust/tests/util/mojom_validation.rs b/mojo/public/rust/tests/util/mojom_validation.rs |
| index 2b0720e3e8e39051d04b0a727236fc64eee6d8eb..a896dac77d85e90e0d99ec63d6efb68903663dd3 100644 |
| --- a/mojo/public/rust/tests/util/mojom_validation.rs |
| +++ b/mojo/public/rust/tests/util/mojom_validation.rs |
| @@ -4,7 +4,8 @@ |
| #![allow(unused_variables)] |
| #![allow(dead_code)] |
| -use mojo::bindings::decoding::Decoder; |
| +use mojo::bindings::decoding; |
| +use mojo::bindings::decoding::{Decoder, ValidationError}; |
| use mojo::bindings::encoding; |
| use mojo::bindings::encoding::{Context, DataHeaderValue, DATA_HEADER_SIZE, Encoder}; |
| use mojo::bindings::message; |
| @@ -48,16 +49,19 @@ impl MojomPointer for StructA { |
| MojomEncodable::encode(self.i, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructAVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let i = u64::decode(decoder, context.clone()); |
| - StructA { i: i } |
| + let i = match u64::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(StructA { i: i }) |
| } |
| } |
| @@ -93,16 +97,19 @@ impl MojomPointer for StructB { |
| MojomEncodable::encode(self.struct_a, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructBVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let struct_a = match StructA::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let struct_a = StructA::decode(decoder, context.clone()); |
| - StructB { struct_a: struct_a } |
| + Ok(StructB { struct_a: struct_a }) |
| } |
| } |
| @@ -138,16 +145,19 @@ impl MojomPointer for StructC { |
| MojomEncodable::encode(self.data, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructCVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let data = Vec::<u8>::decode(decoder, context.clone()); |
| - StructC { data: data } |
| + let data = match Vec::<u8>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(StructC { data: data }) |
| } |
| } |
| @@ -183,16 +193,20 @@ impl MojomPointer for StructD { |
| MojomEncodable::encode(self.message_pipes, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructDVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let message_pipes = match Vec::<message_pipe::MessageEndpoint>::decode(decoder, |
| + context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let message_pipes = Vec::<message_pipe::MessageEndpoint>::decode(decoder, context.clone()); |
| - StructD { message_pipes: message_pipes } |
| + Ok(StructD { message_pipes: message_pipes }) |
| } |
| } |
| @@ -230,21 +244,27 @@ impl MojomPointer for StructE { |
| MojomEncodable::encode(self.data_pipe_consumer, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructEVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let struct_d = match StructD::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let data_pipe_consumer = match system::data_pipe::Consumer::<u8>::decode(decoder, |
| + context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let struct_d = StructD::decode(decoder, context.clone()); |
| - let data_pipe_consumer = system::data_pipe::Consumer::<u8>::decode(decoder, |
| - context.clone()); |
| - StructE { |
| + Ok(StructE { |
| struct_d: struct_d, |
| data_pipe_consumer: data_pipe_consumer, |
| - } |
| + }) |
| } |
| } |
| @@ -281,16 +301,19 @@ impl MojomPointer for StructF { |
| MojomEncodable::encode(self.fixed_size_array, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructFVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let fixed_size_array = match Box::<[u8; 3]>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let fixed_size_array = Box::<[u8; 3]>::decode(decoder, context.clone()); |
| - StructF { fixed_size_array: fixed_size_array } |
| + Ok(StructF { fixed_size_array: fixed_size_array }) |
| } |
| } |
| @@ -332,36 +355,48 @@ impl MojomPointer for StructG { |
| MojomEncodable::encode(self.str, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructGVersions) { |
|
Eric Holk
2016/08/08 20:34:15
You use this pattern a lot, but I think it's basic
mknyszek
2016/08/08 21:32:22
Oh, wow, yeah I completely forgot about the try! m
|
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let i = match i32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let i = i32::decode(decoder, context.clone()); |
| let b = if version >= 3 { |
| - bool::decode(decoder, context.clone()) |
| + match bool::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| } else { |
| Default::default() |
| }; |
| let struct_a = if version >= 1 { |
| - Option::<StructA>::decode(decoder, context.clone()) |
| + match Option::<StructA>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| } else { |
| Default::default() |
| }; |
| let str = if version >= 3 { |
| - Option::<String>::decode(decoder, context.clone()) |
| + match Option::<String>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| } else { |
| Default::default() |
| }; |
| - StructG { |
| + Ok(StructG { |
| i: i, |
| b: b, |
| struct_a: struct_a, |
| str: str, |
| - } |
| + }) |
| } |
| } |
| @@ -406,26 +441,41 @@ impl MojomPointer for StructH { |
| MojomEncodable::encode(self.e, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| - }; |
| - let a = bool::decode(decoder, context.clone()); |
| - let b = u8::decode(decoder, context.clone()); |
| - let c = Option::<UnionA>::decode(decoder, context.clone()); |
| - let d = Option::<Vec<UnionA>>::decode(decoder, context.clone()); |
| - let e = Option::<HashMap<u8, UnionA>>::decode(decoder, context.clone()); |
| - StructH { |
| + match state.decode_struct_header(&StructHVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let a = match bool::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let b = match u8::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let c = match Option::<UnionA>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let d = match Option::<Vec<UnionA>>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let e = match Option::<HashMap<u8, UnionA>>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(StructH { |
| a: a, |
| b: b, |
| c: c, |
| d: d, |
| e: e, |
| - } |
| + }) |
| } |
| } |
| @@ -463,16 +513,19 @@ impl MojomPointer for BasicStruct { |
| MojomEncodable::encode(self.a, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&BasicStructVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let a = i32::decode(decoder, context.clone()); |
| - BasicStruct { a: a } |
| + let a = match i32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(BasicStruct { a: a }) |
| } |
| } |
| @@ -513,15 +566,15 @@ impl MojomPointer for StructWithEnum { |
| 8 |
| } |
| fn encode_value(self, encoder: &mut Encoder, context: Context) {} |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&StructWithEnumVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - StructWithEnum {} |
| + Ok(StructWithEnum {}) |
| } |
| } |
| @@ -600,29 +653,98 @@ impl MojomUnion for UnionA { |
| UnionA::_Unknown(val) => MojomEncodable::encode(val, encoder, context.clone()), |
| } |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and tag |
| - let (_bytes, tag) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let tag = { |
| let mut state = decoder.get_mut(&context); |
| let bytes = state.decode::<u32>(); |
| - let tag = state.decode::<u32>(); |
| - (bytes, tag) |
| - }; |
| - match tag { |
| - UnionATag_a => UnionA::a(u16::decode(decoder, context.clone())), |
| - UnionATag_b => UnionA::b(u32::decode(decoder, context.clone())), |
| - UnionATag_c => UnionA::c(Option::<StructA>::decode(decoder, context.clone())), |
| - UnionATag_d => UnionA::d(Option::<Vec<u8>>::decode(decoder, context.clone())), |
| + if (bytes as usize) != UNION_SIZE { |
| + return Err(ValidationError::UnexpectedNullUnion); |
| + } |
| + state.decode::<u32>() |
| + }; |
| + Ok(match tag { |
| + UnionATag_a => { |
| + UnionA::a({ |
| + match u16::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_b => { |
| + UnionA::b({ |
| + match u32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_c => { |
| + UnionA::c({ |
| + match Option::<StructA>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_d => { |
| + UnionA::d({ |
| + match Option::<Vec<u8>>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| UnionATag_e => { |
| - UnionA::e(Option::<HashMap<String, u8>>::decode(decoder, context.clone())) |
| - } |
| - UnionATag_f => UnionA::f(Option::<UnionB>::decode(decoder, context.clone())), |
| - UnionATag_g => UnionA::g(StructA::decode(decoder, context.clone())), |
| - UnionATag_h => UnionA::h(Vec::<u8>::decode(decoder, context.clone())), |
| - UnionATag_i => UnionA::i(HashMap::<String, u8>::decode(decoder, context.clone())), |
| - UnionATag_j => UnionA::j(UnionB::decode(decoder, context.clone())), |
| - _ => UnionA::_Unknown(u64::decode(decoder, context.clone())), |
| - } |
| + UnionA::e({ |
| + match Option::<HashMap<String, u8>>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_f => { |
| + UnionA::f({ |
| + match Option::<UnionB>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_g => { |
| + UnionA::g({ |
| + match StructA::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_h => { |
| + UnionA::h({ |
| + match Vec::<u8>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_i => { |
| + UnionA::i({ |
| + match HashMap::<String, u8>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionATag_j => { |
| + UnionA::j({ |
| + match UnionB::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + _ => UnionA::_Unknown(u64::decode(decoder, context.clone()).unwrap()), |
| + }) |
| } |
| } |
| @@ -686,21 +808,50 @@ impl MojomUnion for UnionB { |
| UnionB::_Unknown(val) => MojomEncodable::encode(val, encoder, context.clone()), |
| } |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and tag |
| - let (_bytes, tag) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let tag = { |
| let mut state = decoder.get_mut(&context); |
| let bytes = state.decode::<u32>(); |
| - let tag = state.decode::<u32>(); |
| - (bytes, tag) |
| - }; |
| - match tag { |
| - UnionBTag_a => UnionB::a(u16::decode(decoder, context.clone())), |
| - UnionBTag_b => UnionB::b(u32::decode(decoder, context.clone())), |
| - UnionBTag_c => UnionB::c(u64::decode(decoder, context.clone())), |
| - UnionBTag_d => UnionB::d(u32::decode(decoder, context.clone())), |
| - _ => UnionB::_Unknown(u64::decode(decoder, context.clone())), |
| - } |
| + if (bytes as usize) != UNION_SIZE { |
| + return Err(ValidationError::UnexpectedNullUnion); |
| + } |
| + state.decode::<u32>() |
| + }; |
| + Ok(match tag { |
| + UnionBTag_a => { |
| + UnionB::a({ |
| + match u16::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionBTag_b => { |
| + UnionB::b({ |
| + match u32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionBTag_c => { |
| + UnionB::c({ |
| + match u64::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + UnionBTag_d => { |
| + UnionB::d({ |
| + match u32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + } |
| + }) |
| + } |
| + _ => UnionB::_Unknown(u64::decode(decoder, context.clone()).unwrap()), |
| + }) |
| } |
| } |
| @@ -841,9 +992,12 @@ pub enum InterfaceARequestOption { |
| } |
| impl MojomMessageOption for InterfaceARequestOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - _ => panic!("Unknown message found: {}", ordinal), |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + match header.name { |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| @@ -853,12 +1007,15 @@ pub enum InterfaceAResponseOption { |
| } |
| impl MojomMessageOption for InterfaceAResponseOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - _ => { |
| - panic!("Unknown message found, or message has no response: {}", |
| - ordinal) |
| - } |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + if header.flags != message::MESSAGE_HEADER_IS_RESPONSE { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match header.name { |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| @@ -972,11 +1129,30 @@ pub enum BoundsCheckTestInterfaceRequestOption { |
| } |
| impl MojomMessageOption for BoundsCheckTestInterfaceRequestOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - BoundsCheckTestInterfaceMethod0::ORDINAL => BoundsCheckTestInterfaceRequestOption::BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0Request::deserialize(buffer, handles)), |
| - BoundsCheckTestInterfaceMethod1::ORDINAL => BoundsCheckTestInterfaceRequestOption::BoundsCheckTestInterfaceMethod1(BoundsCheckTestInterfaceMethod1Request::deserialize(buffer, handles)), |
| - _ => panic!("Unknown message found: {}", ordinal), |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + match header.name { |
| + BoundsCheckTestInterfaceMethod0::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_EXPECT_RESPONSE { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match BoundsCheckTestInterfaceMethod0Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(BoundsCheckTestInterfaceRequestOption::BoundsCheckTestInterfaceMethod0(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + BoundsCheckTestInterfaceMethod1::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match BoundsCheckTestInterfaceMethod1Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(BoundsCheckTestInterfaceRequestOption::BoundsCheckTestInterfaceMethod1(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| @@ -986,13 +1162,21 @@ pub enum BoundsCheckTestInterfaceResponseOption { |
| } |
| impl MojomMessageOption for BoundsCheckTestInterfaceResponseOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - BoundsCheckTestInterfaceMethod0::ORDINAL => BoundsCheckTestInterfaceResponseOption::BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0Response::deserialize(buffer, handles)), |
| - _ => { |
| - panic!("Unknown message found, or message has no response: {}", |
| - ordinal) |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + if header.flags != message::MESSAGE_HEADER_IS_RESPONSE { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match header.name { |
| + BoundsCheckTestInterfaceMethod0::ORDINAL => { |
| + match BoundsCheckTestInterfaceMethod0Response::deserialize(buffer, handles) { |
| + Ok(value) => Ok(BoundsCheckTestInterfaceResponseOption::BoundsCheckTestInterfaceMethod0(value)), |
| + Err(err) => return Err(err), |
| + } |
| } |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| @@ -1025,16 +1209,19 @@ impl MojomPointer for BoundsCheckTestInterfaceMethod0Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&BoundsCheckTestInterfaceMethod0RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = u8::decode(decoder, context.clone()); |
| - BoundsCheckTestInterfaceMethod0Request { param0: param0 } |
| + let param0 = match u8::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(BoundsCheckTestInterfaceMethod0Request { param0: param0 }) |
| } |
| } |
| @@ -1080,16 +1267,19 @@ impl MojomPointer for BoundsCheckTestInterfaceMethod0Response { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&BoundsCheckTestInterfaceMethod0ResponseVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match u8::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = u8::decode(decoder, context.clone()); |
| - BoundsCheckTestInterfaceMethod0Response { param0: param0 } |
| + Ok(BoundsCheckTestInterfaceMethod0Response { param0: param0 }) |
| } |
| } |
| @@ -1139,16 +1329,19 @@ impl MojomPointer for BoundsCheckTestInterfaceMethod1Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&BoundsCheckTestInterfaceMethod1RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = u8::decode(decoder, context.clone()); |
| - BoundsCheckTestInterfaceMethod1Request { param0: param0 } |
| + let param0 = match u8::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(BoundsCheckTestInterfaceMethod1Request { param0: param0 }) |
| } |
| } |
| @@ -1275,44 +1468,175 @@ pub trait ConformanceTestInterfaceRequest: MojomMessage {} |
| pub trait ConformanceTestInterfaceResponse: MojomMessage {} |
| pub enum ConformanceTestInterfaceRequestOption { |
| - ConformanceTestInterfaceMethod8(ConformanceTestInterfaceMethod8Request), |
| - ConformanceTestInterfaceMethod15(ConformanceTestInterfaceMethod15Request), |
| ConformanceTestInterfaceMethod0(ConformanceTestInterfaceMethod0Request), |
| + ConformanceTestInterfaceMethod11(ConformanceTestInterfaceMethod11Request), |
| ConformanceTestInterfaceMethod1(ConformanceTestInterfaceMethod1Request), |
| - ConformanceTestInterfaceMethod4(ConformanceTestInterfaceMethod4Request), |
| - ConformanceTestInterfaceMethod6(ConformanceTestInterfaceMethod6Request), |
| - ConformanceTestInterfaceMethod7(ConformanceTestInterfaceMethod7Request), |
| - ConformanceTestInterfaceMethod14(ConformanceTestInterfaceMethod14Request), |
| - ConformanceTestInterfaceMethod2(ConformanceTestInterfaceMethod2Request), |
| ConformanceTestInterfaceMethod9(ConformanceTestInterfaceMethod9Request), |
| - ConformanceTestInterfaceMethod11(ConformanceTestInterfaceMethod11Request), |
| - ConformanceTestInterfaceMethod13(ConformanceTestInterfaceMethod13Request), |
| + ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Request), |
| + ConformanceTestInterfaceMethod15(ConformanceTestInterfaceMethod15Request), |
| ConformanceTestInterfaceMethod3(ConformanceTestInterfaceMethod3Request), |
| ConformanceTestInterfaceMethod5(ConformanceTestInterfaceMethod5Request), |
| + ConformanceTestInterfaceMethod6(ConformanceTestInterfaceMethod6Request), |
| + ConformanceTestInterfaceMethod8(ConformanceTestInterfaceMethod8Request), |
| + ConformanceTestInterfaceMethod13(ConformanceTestInterfaceMethod13Request), |
| + ConformanceTestInterfaceMethod2(ConformanceTestInterfaceMethod2Request), |
| + ConformanceTestInterfaceMethod4(ConformanceTestInterfaceMethod4Request), |
| + ConformanceTestInterfaceMethod7(ConformanceTestInterfaceMethod7Request), |
| ConformanceTestInterfaceMethod10(ConformanceTestInterfaceMethod10Request), |
| - ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Request), |
| + ConformanceTestInterfaceMethod14(ConformanceTestInterfaceMethod14Request), |
| } |
| impl MojomMessageOption for ConformanceTestInterfaceRequestOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - ConformanceTestInterfaceMethod8::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod8(ConformanceTestInterfaceMethod8Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod15::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod15(ConformanceTestInterfaceMethod15Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod0::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod0(ConformanceTestInterfaceMethod0Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod1::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod1(ConformanceTestInterfaceMethod1Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod4::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod4(ConformanceTestInterfaceMethod4Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod6::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod6(ConformanceTestInterfaceMethod6Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod7::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod7(ConformanceTestInterfaceMethod7Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod14::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod14(ConformanceTestInterfaceMethod14Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod2::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod2(ConformanceTestInterfaceMethod2Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod9::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod9(ConformanceTestInterfaceMethod9Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod11::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod11(ConformanceTestInterfaceMethod11Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod13::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod13(ConformanceTestInterfaceMethod13Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod3::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod3(ConformanceTestInterfaceMethod3Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod5::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod5(ConformanceTestInterfaceMethod5Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod10::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod10(ConformanceTestInterfaceMethod10Request::deserialize(buffer, handles)), |
| - ConformanceTestInterfaceMethod12::ORDINAL => ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Request::deserialize(buffer, handles)), |
| - _ => panic!("Unknown message found: {}", ordinal), |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + match header.name { |
| + ConformanceTestInterfaceMethod0::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod0Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod0(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod11::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod11Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod11(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod1::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod1Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod1(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod9::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod9Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod9(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod12::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_EXPECT_RESPONSE { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod12Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod12(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod15::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod15Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod15(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod3::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod3Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod3(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod5::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod5Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod5(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod6::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod6Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod6(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod8::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod8Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod8(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod13::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod13Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod13(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod2::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod2Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod2(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod4::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod4Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod4(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod7::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod7Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod7(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod10::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod10Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod10(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + ConformanceTestInterfaceMethod14::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_NO_FLAG { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match ConformanceTestInterfaceMethod14Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceRequestOption::ConformanceTestInterfaceMethod14(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| @@ -1322,35 +1646,43 @@ pub enum ConformanceTestInterfaceResponseOption { |
| } |
| impl MojomMessageOption for ConformanceTestInterfaceResponseOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - ConformanceTestInterfaceMethod12::ORDINAL => ConformanceTestInterfaceResponseOption::ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Response::deserialize(buffer, handles)), |
| - _ => { |
| - panic!("Unknown message found, or message has no response: {}", |
| - ordinal) |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + if header.flags != message::MESSAGE_HEADER_IS_RESPONSE { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match header.name { |
| + ConformanceTestInterfaceMethod12::ORDINAL => { |
| + match ConformanceTestInterfaceMethod12Response::deserialize(buffer, handles) { |
| + Ok(value) => Ok(ConformanceTestInterfaceResponseOption::ConformanceTestInterfaceMethod12(value)), |
| + Err(err) => return Err(err), |
| + } |
| } |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| -/// Message: ConformanceTestInterfaceMethod8 |
| -pub mod ConformanceTestInterfaceMethod8 { |
| - pub const ORDINAL: u32 = 8; |
| +/// Message: ConformanceTestInterfaceMethod0 |
| +pub mod ConformanceTestInterfaceMethod0 { |
| + pub const ORDINAL: u32 = 0; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod8Request -- |
| +// -- ConformanceTestInterfaceMethod0Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod8RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod0RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod8Request { |
| - pub param0: Vec<Option<Vec<String>>>, |
| +pub struct ConformanceTestInterfaceMethod0Request { |
| + pub param0: f32, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod8Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod0Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1361,20 +1693,23 @@ impl MojomPointer for ConformanceTestInterfaceMethod8Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod0RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = Vec::<Option<Vec<String>>>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod8Request { param0: param0 } |
| + let param0 = match f32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod0Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod8Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod0Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1382,35 +1717,35 @@ impl MojomEncodable for ConformanceTestInterfaceMethod8Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod8Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod8Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod0Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod0Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod8::ORDINAL, |
| + ConformanceTestInterfaceMethod0::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod8Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod0Request {} |
| -/// Message: ConformanceTestInterfaceMethod15 |
| -pub mod ConformanceTestInterfaceMethod15 { |
| - pub const ORDINAL: u32 = 15; |
| +/// Message: ConformanceTestInterfaceMethod11 |
| +pub mod ConformanceTestInterfaceMethod11 { |
| + pub const ORDINAL: u32 = 11; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod15Request -- |
| +// -- ConformanceTestInterfaceMethod11Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod15RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod11RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod15Request { |
| - pub param0: StructH, |
| +pub struct ConformanceTestInterfaceMethod11Request { |
| + pub param0: StructG, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod15Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod11Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1421,20 +1756,23 @@ impl MojomPointer for ConformanceTestInterfaceMethod15Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod11RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match StructG::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = StructH::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod15Request { param0: param0 } |
| + Ok(ConformanceTestInterfaceMethod11Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod15Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod11Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1442,35 +1780,35 @@ impl MojomEncodable for ConformanceTestInterfaceMethod15Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod15Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod15Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod11Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod11Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod15::ORDINAL, |
| + ConformanceTestInterfaceMethod11::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod15Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod11Request {} |
| -/// Message: ConformanceTestInterfaceMethod0 |
| -pub mod ConformanceTestInterfaceMethod0 { |
| - pub const ORDINAL: u32 = 0; |
| +/// Message: ConformanceTestInterfaceMethod1 |
| +pub mod ConformanceTestInterfaceMethod1 { |
| + pub const ORDINAL: u32 = 1; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod0Request -- |
| +// -- ConformanceTestInterfaceMethod1Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod0RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod1RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod0Request { |
| - pub param0: f32, |
| +pub struct ConformanceTestInterfaceMethod1Request { |
| + pub param0: StructA, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod0Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod1Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1481,20 +1819,23 @@ impl MojomPointer for ConformanceTestInterfaceMethod0Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod1RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = f32::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod0Request { param0: param0 } |
| + let param0 = match StructA::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod1Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod0Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod1Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1502,35 +1843,35 @@ impl MojomEncodable for ConformanceTestInterfaceMethod0Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod0Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod0Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod1Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod1Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod0::ORDINAL, |
| + ConformanceTestInterfaceMethod1::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod0Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod1Request {} |
| -/// Message: ConformanceTestInterfaceMethod1 |
| -pub mod ConformanceTestInterfaceMethod1 { |
| - pub const ORDINAL: u32 = 1; |
| +/// Message: ConformanceTestInterfaceMethod9 |
| +pub mod ConformanceTestInterfaceMethod9 { |
| + pub const ORDINAL: u32 = 9; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod1Request -- |
| +// -- ConformanceTestInterfaceMethod9Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod1RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod9RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod1Request { |
| - pub param0: StructA, |
| +pub struct ConformanceTestInterfaceMethod9Request { |
| + pub param0: Option<Vec<Vec<Option<system::UntypedHandle>>>>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod1Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod9Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1541,20 +1882,25 @@ impl MojomPointer for ConformanceTestInterfaceMethod1Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod9RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = StructA::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod1Request { param0: param0 } |
| + let param0 = |
| + match Option::<Vec<Vec<Option<system::UntypedHandle>>>>::decode(decoder, |
| + context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod9Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod1Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod9Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1562,102 +1908,93 @@ impl MojomEncodable for ConformanceTestInterfaceMethod1Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod1Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod1Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod9Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod9Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod1::ORDINAL, |
| + ConformanceTestInterfaceMethod9::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod1Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod9Request {} |
| -/// Message: ConformanceTestInterfaceMethod4 |
| -pub mod ConformanceTestInterfaceMethod4 { |
| - pub const ORDINAL: u32 = 4; |
| +/// Message: ConformanceTestInterfaceMethod12 |
| +pub mod ConformanceTestInterfaceMethod12 { |
| + pub const ORDINAL: u32 = 12; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod4Request -- |
| +// -- ConformanceTestInterfaceMethod12Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod4RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| +const ConformanceTestInterfaceMethod12RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod4Request { |
| - pub param0: StructC, |
| - pub param1: Vec<u8>, |
| +pub struct ConformanceTestInterfaceMethod12Request { |
| + pub param0: f32, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod4Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod12Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| fn serialized_size(&self, _context: &Context) -> usize { |
| - 24 |
| + 16 |
| } |
| fn encode_value(self, encoder: &mut Encoder, context: Context) { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| - MojomEncodable::encode(self.param1, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod12RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = StructC::decode(decoder, context.clone()); |
| - let param1 = Vec::<u8>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod4Request { |
| - param0: param0, |
| - param1: param1, |
| - } |
| + let param0 = match f32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod12Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod4Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod12Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| - self.param0.compute_size(context.clone()) + |
| - self.param1.compute_size(context.clone()) |
| + self.param0.compute_size(context.clone()) |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod4Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod4Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod12Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod12Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod4::ORDINAL, |
| - message::MESSAGE_HEADER_NO_FLAG) |
| + ConformanceTestInterfaceMethod12::ORDINAL, |
| + message::MESSAGE_HEADER_EXPECT_RESPONSE) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod4Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod12Request {} |
| -/// Message: ConformanceTestInterfaceMethod6 |
| -pub mod ConformanceTestInterfaceMethod6 { |
| - pub const ORDINAL: u32 = 6; |
| - pub const MIN_VERSION: u32 = 0; |
| -} |
| -// -- ConformanceTestInterfaceMethod6Request -- |
| +// -- ConformanceTestInterfaceMethod12Response -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod6RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod12ResponseVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod6Request { |
| - pub param0: Vec<Vec<u8>>, |
| +pub struct ConformanceTestInterfaceMethod12Response { |
| + pub param0: f32, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod6Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod12Response { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1668,20 +2005,23 @@ impl MojomPointer for ConformanceTestInterfaceMethod6Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod12ResponseVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = Vec::<Vec<u8>>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod6Request { param0: param0 } |
| + let param0 = match f32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod12Response { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod6Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod12Response { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1689,126 +2029,124 @@ impl MojomEncodable for ConformanceTestInterfaceMethod6Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod6Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod6Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod12Response {} |
| + |
| +impl MojomMessage for ConformanceTestInterfaceMethod12Response { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod6::ORDINAL, |
| - message::MESSAGE_HEADER_NO_FLAG) |
| - |
| + ConformanceTestInterfaceMethod12::ORDINAL, |
| + message::MESSAGE_HEADER_IS_RESPONSE) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod6Request {} |
| - |
| -/// Message: ConformanceTestInterfaceMethod7 |
| -pub mod ConformanceTestInterfaceMethod7 { |
| - pub const ORDINAL: u32 = 7; |
| +impl ConformanceTestInterfaceResponse for ConformanceTestInterfaceMethod12Request {} |
| +/// Message: ConformanceTestInterfaceMethod15 |
| +pub mod ConformanceTestInterfaceMethod15 { |
| + pub const ORDINAL: u32 = 15; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod7Request -- |
| +// -- ConformanceTestInterfaceMethod15Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod7RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| +const ConformanceTestInterfaceMethod15RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod7Request { |
| - pub param0: StructF, |
| - pub param1: Box<[Option<Box<[u8; 3]>>; 2]>, |
| +pub struct ConformanceTestInterfaceMethod15Request { |
| + pub param0: StructH, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod7Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod15Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| fn serialized_size(&self, _context: &Context) -> usize { |
| - 24 |
| + 16 |
| } |
| fn encode_value(self, encoder: &mut Encoder, context: Context) { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| - MojomEncodable::encode(self.param1, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod15RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = StructF::decode(decoder, context.clone()); |
| - let param1 = Box::<[Option<Box<[u8; 3]>>; 2]>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod7Request { |
| - param0: param0, |
| - param1: param1, |
| - } |
| + let param0 = match StructH::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod15Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod7Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod15Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| - self.param0.compute_size(context.clone()) + |
| - self.param1.compute_size(context.clone()) |
| + self.param0.compute_size(context.clone()) |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod7Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod7Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod15Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod15Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod7::ORDINAL, |
| + ConformanceTestInterfaceMethod15::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod7Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod15Request {} |
| -/// Message: ConformanceTestInterfaceMethod14 |
| -pub mod ConformanceTestInterfaceMethod14 { |
| - pub const ORDINAL: u32 = 14; |
| +/// Message: ConformanceTestInterfaceMethod3 |
| +pub mod ConformanceTestInterfaceMethod3 { |
| + pub const ORDINAL: u32 = 3; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod14Request -- |
| +// -- ConformanceTestInterfaceMethod3Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod14RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| +const ConformanceTestInterfaceMethod3RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod14Request { |
| - pub param0: UnionA, |
| +pub struct ConformanceTestInterfaceMethod3Request { |
| + pub param0: Vec<bool>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod14Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod3Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| fn serialized_size(&self, _context: &Context) -> usize { |
| - 24 |
| + 16 |
| } |
| fn encode_value(self, encoder: &mut Encoder, context: Context) { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod3RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = UnionA::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod14Request { param0: param0 } |
| + let param0 = match Vec::<bool>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod3Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod14Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod3Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1816,36 +2154,36 @@ impl MojomEncodable for ConformanceTestInterfaceMethod14Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod14Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod14Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod3Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod3Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod14::ORDINAL, |
| + ConformanceTestInterfaceMethod3::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod14Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod3Request {} |
| -/// Message: ConformanceTestInterfaceMethod2 |
| -pub mod ConformanceTestInterfaceMethod2 { |
| - pub const ORDINAL: u32 = 2; |
| +/// Message: ConformanceTestInterfaceMethod5 |
| +pub mod ConformanceTestInterfaceMethod5 { |
| + pub const ORDINAL: u32 = 5; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod2Request -- |
| +// -- ConformanceTestInterfaceMethod5Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod2RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| +const ConformanceTestInterfaceMethod5RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod2Request { |
| - pub param0: StructB, |
| - pub param1: StructA, |
| +pub struct ConformanceTestInterfaceMethod5Request { |
| + pub param0: StructE, |
| + pub param1: system::data_pipe::Producer<u8>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod2Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod5Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1857,24 +2195,30 @@ impl MojomPointer for ConformanceTestInterfaceMethod2Request { |
| MojomEncodable::encode(self.param1, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod5RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = StructB::decode(decoder, context.clone()); |
| - let param1 = StructA::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod2Request { |
| + let param0 = match StructE::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let param1 = match system::data_pipe::Producer::<u8>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod5Request { |
| param0: param0, |
| param1: param1, |
| - } |
| + }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod2Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod5Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1883,35 +2227,35 @@ impl MojomEncodable for ConformanceTestInterfaceMethod2Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod2Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod2Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod5Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod5Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod2::ORDINAL, |
| + ConformanceTestInterfaceMethod5::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod2Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod5Request {} |
| -/// Message: ConformanceTestInterfaceMethod9 |
| -pub mod ConformanceTestInterfaceMethod9 { |
| - pub const ORDINAL: u32 = 9; |
| +/// Message: ConformanceTestInterfaceMethod6 |
| +pub mod ConformanceTestInterfaceMethod6 { |
| + pub const ORDINAL: u32 = 6; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod9Request -- |
| +// -- ConformanceTestInterfaceMethod6Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod9RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod6RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod9Request { |
| - pub param0: Option<Vec<Vec<Option<system::UntypedHandle>>>>, |
| +pub struct ConformanceTestInterfaceMethod6Request { |
| + pub param0: Vec<Vec<u8>>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod9Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod6Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1922,21 +2266,23 @@ impl MojomPointer for ConformanceTestInterfaceMethod9Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod6RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = Option::<Vec<Vec<Option<system::UntypedHandle>>>>::decode(decoder, |
| - context.clone()); |
| - ConformanceTestInterfaceMethod9Request { param0: param0 } |
| + let param0 = match Vec::<Vec<u8>>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod6Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod9Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod6Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -1944,35 +2290,35 @@ impl MojomEncodable for ConformanceTestInterfaceMethod9Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod9Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod9Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod6Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod6Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod9::ORDINAL, |
| + ConformanceTestInterfaceMethod6::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod9Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod6Request {} |
| -/// Message: ConformanceTestInterfaceMethod11 |
| -pub mod ConformanceTestInterfaceMethod11 { |
| - pub const ORDINAL: u32 = 11; |
| +/// Message: ConformanceTestInterfaceMethod8 |
| +pub mod ConformanceTestInterfaceMethod8 { |
| + pub const ORDINAL: u32 = 8; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod11Request -- |
| +// -- ConformanceTestInterfaceMethod8Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod11RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod8RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod11Request { |
| - pub param0: StructG, |
| +pub struct ConformanceTestInterfaceMethod8Request { |
| + pub param0: Vec<Option<Vec<String>>>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod11Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod8Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -1983,20 +2329,23 @@ impl MojomPointer for ConformanceTestInterfaceMethod11Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod8RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match Vec::<Option<Vec<String>>>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = StructG::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod11Request { param0: param0 } |
| + Ok(ConformanceTestInterfaceMethod8Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod11Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod8Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -2004,16 +2353,16 @@ impl MojomEncodable for ConformanceTestInterfaceMethod11Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod11Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod11Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod8Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod8Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod11::ORDINAL, |
| + ConformanceTestInterfaceMethod8::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod11Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod8Request {} |
| /// Message: ConformanceTestInterfaceMethod13 |
| pub mod ConformanceTestInterfaceMethod13 { |
| @@ -2047,22 +2396,31 @@ impl MojomPointer for ConformanceTestInterfaceMethod13Request { |
| MojomEncodable::encode(self.param2, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod13RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match Option::<InterfaceAClient>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = Option::<InterfaceAClient>::decode(decoder, context.clone()); |
| - let param1 = u32::decode(decoder, context.clone()); |
| - let param2 = Option::<InterfaceAClient>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod13Request { |
| + let param1 = match u32::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let param2 = match Option::<InterfaceAClient>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod13Request { |
| param0: param0, |
| param1: param1, |
| param2: param2, |
| - } |
| + }) |
| } |
| } |
| @@ -2087,85 +2445,98 @@ impl MojomMessage for ConformanceTestInterfaceMethod13Request { |
| } |
| impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod13Request {} |
| -/// Message: ConformanceTestInterfaceMethod3 |
| -pub mod ConformanceTestInterfaceMethod3 { |
| - pub const ORDINAL: u32 = 3; |
| +/// Message: ConformanceTestInterfaceMethod2 |
| +pub mod ConformanceTestInterfaceMethod2 { |
| + pub const ORDINAL: u32 = 2; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod3Request -- |
| +// -- ConformanceTestInterfaceMethod2Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod3RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod2RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod3Request { |
| - pub param0: Vec<bool>, |
| +pub struct ConformanceTestInterfaceMethod2Request { |
| + pub param0: StructB, |
| + pub param1: StructA, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod3Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod2Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| fn serialized_size(&self, _context: &Context) -> usize { |
| - 16 |
| + 24 |
| } |
| fn encode_value(self, encoder: &mut Encoder, context: Context) { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| + MojomEncodable::encode(self.param1, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod2RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = Vec::<bool>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod3Request { param0: param0 } |
| + let param0 = match StructB::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let param1 = match StructA::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod2Request { |
| + param0: param0, |
| + param1: param1, |
| + }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod3Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod2Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| - self.param0.compute_size(context.clone()) |
| + self.param0.compute_size(context.clone()) + |
| + self.param1.compute_size(context.clone()) |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod3Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod3Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod2Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod2Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod3::ORDINAL, |
| + ConformanceTestInterfaceMethod2::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod3Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod2Request {} |
| -/// Message: ConformanceTestInterfaceMethod5 |
| -pub mod ConformanceTestInterfaceMethod5 { |
| - pub const ORDINAL: u32 = 5; |
| +/// Message: ConformanceTestInterfaceMethod4 |
| +pub mod ConformanceTestInterfaceMethod4 { |
| + pub const ORDINAL: u32 = 4; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod5Request -- |
| +// -- ConformanceTestInterfaceMethod4Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod5RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| +const ConformanceTestInterfaceMethod4RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod5Request { |
| - pub param0: StructE, |
| - pub param1: system::data_pipe::Producer<u8>, |
| +pub struct ConformanceTestInterfaceMethod4Request { |
| + pub param0: StructC, |
| + pub param1: Vec<u8>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod5Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod4Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -2177,24 +2548,30 @@ impl MojomPointer for ConformanceTestInterfaceMethod5Request { |
| MojomEncodable::encode(self.param1, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod4RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = StructE::decode(decoder, context.clone()); |
| - let param1 = system::data_pipe::Producer::<u8>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod5Request { |
| + let param0 = match StructC::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let param1 = match Vec::<u8>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod4Request { |
| param0: param0, |
| param1: param1, |
| - } |
| + }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod5Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod4Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -2203,95 +2580,108 @@ impl MojomEncodable for ConformanceTestInterfaceMethod5Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod5Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod5Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod4Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod4Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod5::ORDINAL, |
| + ConformanceTestInterfaceMethod4::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod5Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod4Request {} |
| -/// Message: ConformanceTestInterfaceMethod10 |
| -pub mod ConformanceTestInterfaceMethod10 { |
| - pub const ORDINAL: u32 = 10; |
| +/// Message: ConformanceTestInterfaceMethod7 |
| +pub mod ConformanceTestInterfaceMethod7 { |
| + pub const ORDINAL: u32 = 7; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod10Request -- |
| +// -- ConformanceTestInterfaceMethod7Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod10RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod7RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod10Request { |
| - pub param0: HashMap<String, u8>, |
| +pub struct ConformanceTestInterfaceMethod7Request { |
| + pub param0: StructF, |
| + pub param1: Box<[Option<Box<[u8; 3]>>; 2]>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod10Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod7Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| fn serialized_size(&self, _context: &Context) -> usize { |
| - 16 |
| + 24 |
| } |
| fn encode_value(self, encoder: &mut Encoder, context: Context) { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| + MojomEncodable::encode(self.param1, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod7RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| }; |
| - let param0 = HashMap::<String, u8>::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod10Request { param0: param0 } |
| + let param0 = match StructF::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + let param1 = match Box::<[Option<Box<[u8; 3]>>; 2]>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| + }; |
| + Ok(ConformanceTestInterfaceMethod7Request { |
| + param0: param0, |
| + param1: param1, |
| + }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod10Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod7Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| - self.param0.compute_size(context.clone()) |
| + self.param0.compute_size(context.clone()) + |
| + self.param1.compute_size(context.clone()) |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod10Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod10Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod7Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod7Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod10::ORDINAL, |
| + ConformanceTestInterfaceMethod7::ORDINAL, |
| message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod10Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod7Request {} |
| -/// Message: ConformanceTestInterfaceMethod12 |
| -pub mod ConformanceTestInterfaceMethod12 { |
| - pub const ORDINAL: u32 = 12; |
| +/// Message: ConformanceTestInterfaceMethod10 |
| +pub mod ConformanceTestInterfaceMethod10 { |
| + pub const ORDINAL: u32 = 10; |
| pub const MIN_VERSION: u32 = 0; |
| } |
| -// -- ConformanceTestInterfaceMethod12Request -- |
| +// -- ConformanceTestInterfaceMethod10Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod12RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod10RequestVersions: [(u32, u32); 1] = [(0, 16)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod12Request { |
| - pub param0: f32, |
| +pub struct ConformanceTestInterfaceMethod10Request { |
| + pub param0: HashMap<String, u8>, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod12Request { |
| +impl MojomPointer for ConformanceTestInterfaceMethod10Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| @@ -2302,20 +2692,23 @@ impl MojomPointer for ConformanceTestInterfaceMethod12Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod10RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match HashMap::<String, u8>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = f32::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod12Request { param0: param0 } |
| + Ok(ConformanceTestInterfaceMethod10Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod12Request { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod10Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -2323,54 +2716,62 @@ impl MojomEncodable for ConformanceTestInterfaceMethod12Request { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod12Request {} |
| -impl MojomMessage for ConformanceTestInterfaceMethod12Request { |
| +impl MojomStruct for ConformanceTestInterfaceMethod10Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod10Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod12::ORDINAL, |
| - message::MESSAGE_HEADER_EXPECT_RESPONSE) |
| + ConformanceTestInterfaceMethod10::ORDINAL, |
| + message::MESSAGE_HEADER_NO_FLAG) |
| } |
| } |
| -impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod12Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod10Request {} |
| -// -- ConformanceTestInterfaceMethod12Response -- |
| +/// Message: ConformanceTestInterfaceMethod14 |
| +pub mod ConformanceTestInterfaceMethod14 { |
| + pub const ORDINAL: u32 = 14; |
| + pub const MIN_VERSION: u32 = 0; |
| +} |
| +// -- ConformanceTestInterfaceMethod14Request -- |
| // Constants |
| // Enums |
| // Struct version information |
| -const ConformanceTestInterfaceMethod12ResponseVersions: [(u32, u32); 1] = [(0, 16)]; |
| +const ConformanceTestInterfaceMethod14RequestVersions: [(u32, u32); 1] = [(0, 24)]; |
| // Struct definition |
| -pub struct ConformanceTestInterfaceMethod12Response { |
| - pub param0: f32, |
| +pub struct ConformanceTestInterfaceMethod14Request { |
| + pub param0: UnionA, |
| } |
| -impl MojomPointer for ConformanceTestInterfaceMethod12Response { |
| +impl MojomPointer for ConformanceTestInterfaceMethod14Request { |
| fn header_data(&self) -> DataHeaderValue { |
| DataHeaderValue::Version(0) |
| } |
| fn serialized_size(&self, _context: &Context) -> usize { |
| - 16 |
| + 24 |
| } |
| fn encode_value(self, encoder: &mut Encoder, context: Context) { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&ConformanceTestInterfaceMethod14RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match UnionA::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = f32::decode(decoder, context.clone()); |
| - ConformanceTestInterfaceMethod12Response { param0: param0 } |
| + Ok(ConformanceTestInterfaceMethod14Request { param0: param0 }) |
| } |
| } |
| -impl MojomEncodable for ConformanceTestInterfaceMethod12Response { |
| +impl MojomEncodable for ConformanceTestInterfaceMethod14Request { |
| impl_encodable_for_pointer!(); |
| fn compute_size(&self, context: Context) -> usize { |
| encoding::align_default(self.serialized_size(&context)) + |
| @@ -2378,16 +2779,18 @@ impl MojomEncodable for ConformanceTestInterfaceMethod12Response { |
| } |
| } |
| -impl MojomStruct for ConformanceTestInterfaceMethod12Response {} |
| - |
| -impl MojomMessage for ConformanceTestInterfaceMethod12Response { |
| +impl MojomStruct for ConformanceTestInterfaceMethod14Request {} |
| +impl MojomMessage for ConformanceTestInterfaceMethod14Request { |
| fn create_header() -> MessageHeader { |
| MessageHeader::new(ConformanceTestInterface::VERSION, |
| - ConformanceTestInterfaceMethod12::ORDINAL, |
| - message::MESSAGE_HEADER_IS_RESPONSE) |
| + ConformanceTestInterfaceMethod14::ORDINAL, |
| + message::MESSAGE_HEADER_NO_FLAG) |
| + |
| } |
| } |
| -impl ConformanceTestInterfaceResponse for ConformanceTestInterfaceMethod12Request {} |
| +impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod14Request {} |
| + |
| + |
| // --- IntegrationTestInterface --- |
| pub mod IntegrationTestInterface { |
| @@ -2495,10 +2898,21 @@ pub enum IntegrationTestInterfaceRequestOption { |
| } |
| impl MojomMessageOption for IntegrationTestInterfaceRequestOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - IntegrationTestInterfaceMethod0::ORDINAL => IntegrationTestInterfaceRequestOption::IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0Request::deserialize(buffer, handles)), |
| - _ => panic!("Unknown message found: {}", ordinal), |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + match header.name { |
| + IntegrationTestInterfaceMethod0::ORDINAL => { |
| + if header.flags != message::MESSAGE_HEADER_EXPECT_RESPONSE { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match IntegrationTestInterfaceMethod0Request::deserialize(buffer, handles) { |
| + Ok(value) => Ok(IntegrationTestInterfaceRequestOption::IntegrationTestInterfaceMethod0(value)), |
| + Err(err) => return Err(err), |
| + } |
| + } |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| @@ -2508,13 +2922,21 @@ pub enum IntegrationTestInterfaceResponseOption { |
| } |
| impl MojomMessageOption for IntegrationTestInterfaceResponseOption { |
| - fn decode_payload(ordinal: u32, buffer: &mut [u8], handles: Vec<UntypedHandle>) -> Self { |
| - match ordinal { |
| - IntegrationTestInterfaceMethod0::ORDINAL => IntegrationTestInterfaceResponseOption::IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0Response::deserialize(buffer, handles)), |
| - _ => { |
| - panic!("Unknown message found, or message has no response: {}", |
| - ordinal) |
| + fn decode_payload(header: MessageHeader, |
| + buffer: &mut [u8], |
| + handles: Vec<UntypedHandle>) |
| + -> Result<Self, ValidationError> { |
| + if header.flags != message::MESSAGE_HEADER_IS_RESPONSE { |
| + return Err(ValidationError::MessageHeaderInvalidFlags); |
| + } |
| + match header.name { |
| + IntegrationTestInterfaceMethod0::ORDINAL => { |
| + match IntegrationTestInterfaceMethod0Response::deserialize(buffer, handles) { |
| + Ok(value) => Ok(IntegrationTestInterfaceResponseOption::IntegrationTestInterfaceMethod0(value)), |
| + Err(err) => return Err(err), |
| + } |
| } |
| + _ => Err(ValidationError::MessageHeaderUnknownMethod), |
| } |
| } |
| } |
| @@ -2547,16 +2969,19 @@ impl MojomPointer for IntegrationTestInterfaceMethod0Request { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&IntegrationTestInterfaceMethod0RequestVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match BasicStruct::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = BasicStruct::decode(decoder, context.clone()); |
| - IntegrationTestInterfaceMethod0Request { param0: param0 } |
| + Ok(IntegrationTestInterfaceMethod0Request { param0: param0 }) |
| } |
| } |
| @@ -2602,16 +3027,19 @@ impl MojomPointer for IntegrationTestInterfaceMethod0Response { |
| MojomEncodable::encode(self.param0, encoder, context.clone()); |
| } |
| - fn decode_value(decoder: &mut Decoder, context: Context) -> Self { |
| - // TODO(mknyszek): Validate bytes and version |
| - let (_bytes, version) = { |
| + fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, ValidationError> { |
| + let version = { |
| let mut state = decoder.get_mut(&context); |
| - let bytes = state.decode::<u32>(); |
| - let version = state.decode::<u32>(); |
| - (bytes, version) |
| + match state.decode_struct_header(&IntegrationTestInterfaceMethod0ResponseVersions) { |
| + Ok(header) => header.data(), |
| + Err(err) => return Err(err), |
| + } |
| + }; |
| + let param0 = match Vec::<u8>::decode(decoder, context.clone()) { |
| + Ok(value) => value, |
| + Err(err) => return Err(err), |
| }; |
| - let param0 = Vec::<u8>::decode(decoder, context.clone()); |
| - IntegrationTestInterfaceMethod0Response { param0: param0 } |
| + Ok(IntegrationTestInterfaceMethod0Response { param0: param0 }) |
| } |
| } |