Fix code generation
This commit is contained in:
+4
-3
@@ -66,15 +66,15 @@ fn map_type_to_rust_accessor(field_type: i32, label: i32) -> (String, String) {
|
|||||||
), // UINT/FIXED 32
|
), // UINT/FIXED 32
|
||||||
16 | 18 => (
|
16 | 18 => (
|
||||||
"i64".to_string(),
|
"i64".to_string(),
|
||||||
"crate::read_varint(bytes).map(|(v, _)| v as i64).map_err(|_| RotoError::WireFormatViolation)".to_string(),
|
"crate::read_varint(bytes).map(|(v, _)| v as i64).map_err(|_| crate::RotoError::WireFormatViolation)".to_string(),
|
||||||
), // SINT/SFIXED 64
|
), // SINT/SFIXED 64
|
||||||
7 | 14 => (
|
7 | 14 => (
|
||||||
"u64".to_string(),
|
"u64".to_string(),
|
||||||
"crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)".to_string(),
|
"crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| crate::RotoError::WireFormatViolation)".to_string(),
|
||||||
), // UINT/FIXED 64
|
), // UINT/FIXED 64
|
||||||
8 => (
|
8 => (
|
||||||
"bool".to_string(),
|
"bool".to_string(),
|
||||||
"crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)".to_string(),
|
"crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| crate::RotoError::WireFormatViolation)".to_string(),
|
||||||
), // TYPE_BOOL
|
), // TYPE_BOOL
|
||||||
11 | 12 => ("&'a [u8]".to_string(), "Ok(bytes)".to_string()), // MESSAGE/BYTES
|
11 | 12 => ("&'a [u8]".to_string(), "Ok(bytes)".to_string()), // MESSAGE/BYTES
|
||||||
_ => ("&'a [u8]".to_string(), "Ok(bytes)".to_string()),
|
_ => ("&'a [u8]".to_string(), "Ok(bytes)".to_string()),
|
||||||
@@ -194,6 +194,7 @@ fn write_message(msg_proto: &DescriptorProto, output: &mut String) {
|
|||||||
output.push_str(" }\n\n");
|
output.push_str(" }\n\n");
|
||||||
|
|
||||||
output.push_str(" Ok(Self {\n");
|
output.push_str(" Ok(Self {\n");
|
||||||
|
output.push_str(" accessor,\n");
|
||||||
for (name, _, _, label) in &fields_info {
|
for (name, _, _, label) in &fields_info {
|
||||||
if *label == 3 {
|
if *label == 3 {
|
||||||
output.push_str(&format!("{}_start, {}_end,\n", name, name));
|
output.push_str(&format!("{}_start, {}_end,\n", name, name));
|
||||||
|
|||||||
Reference in New Issue
Block a user