Serialize and deserialize size/alignment/offset.

These values aren't being used in code generation yet; this will come in a
followup CL.

PiperOrigin-RevId: 397309754
diff --git a/rs_bindings_from_cc/ir.cc b/rs_bindings_from_cc/ir.cc
index 0025aa3..f1c4a97 100644
--- a/rs_bindings_from_cc/ir.cc
+++ b/rs_bindings_from_cc/ir.cc
@@ -77,6 +77,7 @@
   result["type"] = type.ToJson();
   result["identifier"] = identifier.ToJson();
   result["access"] = AccessToString(access);
+  result["offset"] = offset;
   return result;
 }
 
@@ -90,6 +91,8 @@
   nlohmann::json result;
   result["identifier"] = identifier.ToJson();
   result["fields"] = std::move(json_fields);
+  result["size"] = size;
+  result["alignment"] = alignment;
   return result;
 }
 
diff --git a/rs_bindings_from_cc/ir.rs b/rs_bindings_from_cc/ir.rs
index fdd8328..3ec3cad 100644
--- a/rs_bindings_from_cc/ir.rs
+++ b/rs_bindings_from_cc/ir.rs
@@ -59,12 +59,15 @@
     #[serde(rename(deserialize = "type"))]
     pub type_: IRType,
     pub access: AccessSpecifier,
+    pub offset: i64,
 }
 
 #[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
 pub struct Record {
     pub identifier: Identifier,
     pub fields: Vec<Field>,
+    pub size: i64,
+    pub alignment: i64,
 }
 
 #[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Deserialize)]
@@ -154,19 +157,24 @@
                         {
                             "identifier": {"identifier": "public_int" },
                             "type": {"rs_name": "i32", "cc_name": "int", "cc_const": false, "type_params": [] },
-                            "access": "Public"
+                            "access": "Public",
+                            "offset": 0
                         },
                         {
                             "identifier": {"identifier": "protected_int" },
                             "type": {"rs_name": "i32", "cc_name": "int", "cc_const": false, "type_params": [] },
-                            "access": "Protected"
+                            "access": "Protected",
+                            "offset": 32
                         },
                         {
                             "identifier": {"identifier": "private_int" },
                             "type": {"rs_name": "i32", "cc_name": "int", "cc_const": false, "type_params": [] },
-                            "access": "Private"
+                            "access": "Private",
+                            "offset": 64
                         }
-                    ]
+                    ],
+                    "size": 12,
+                    "alignment": 4
                 }
             ]
         }
@@ -185,6 +193,7 @@
                             type_params: vec![],
                         },
                         access: AccessSpecifier::Public,
+                        offset: 0,
                     },
                     Field {
                         identifier: Identifier { identifier: "protected_int".to_string() },
@@ -195,6 +204,7 @@
                             type_params: vec![],
                         },
                         access: AccessSpecifier::Protected,
+                        offset: 32,
                     },
                     Field {
                         identifier: Identifier { identifier: "private_int".to_string() },
@@ -205,8 +215,11 @@
                             type_params: vec![],
                         },
                         access: AccessSpecifier::Private,
+                        offset: 64,
                     },
                 ],
+                size: 12,
+                alignment: 4,
             }],
             ..Default::default()
         };
@@ -226,9 +239,12 @@
                             "type": {"rs_name": "*mut", "cc_name": "*", "cc_const": false, "type_params": [
                                 {"rs_name": "SomeStruct", "cc_name": "SomeStruct", "cc_const": false, "type_params": []}
                             ] },
-                            "access": "Public"
+                            "access": "Public",
+                            "offset": 0
                         }
-                    ]
+                    ],
+                    "size": 8,
+                    "alignment": 8
                 }
             ]
         }
@@ -251,7 +267,10 @@
                         }],
                     },
                     access: AccessSpecifier::Public,
+                    offset: 0,
                 }],
+                size: 8,
+                alignment: 8,
             }],
             ..Default::default()
         };
diff --git a/rs_bindings_from_cc/ir_test.cc b/rs_bindings_from_cc/ir_test.cc
index 14f4a0e..aa8a255 100644
--- a/rs_bindings_from_cc/ir_test.cc
+++ b/rs_bindings_from_cc/ir_test.cc
@@ -51,42 +51,58 @@
                   {
                     "identifier": {"identifier": "public_int" },
                     "type": {"rs_name": "i32", "cc_name": "int", "cc_const": false, "type_params": [] },
-                    "access": "Public"
+                    "access": "Public",
+                    "offset": 0
                   },
                   {
                     "identifier": {"identifier": "protected_int" },
                     "type": {"rs_name": "i32", "cc_name": "int", "cc_const": false, "type_params": [] },
-                    "access": "Protected"
+                    "access": "Protected",
+                    "offset": 32
                   },
                   {
                     "identifier": {"identifier": "private_int" },
                     "type": {"rs_name": "i32", "cc_name": "int", "cc_const": false, "type_params": [] },
-                    "access": "Private"
+                    "access": "Private",
+                    "offset": 64
                   }
-                ]
+                ],
+                "size": 12,
+                "alignment": 4
               }
             ]
       })j");
-  IR ir = {
-      .used_headers = {HeaderName("foo/bar.h")},
-      .functions = {Func{
-          .identifier = Identifier("hello_world"),
-          .mangled_name = "#$mangled_name$#",
-          .return_type = Type{"i32", "int"},
-          .params = {FuncParam{Type{"i32", "int"}, Identifier("arg")}},
-          .is_inline = false}},
-      .records = {Record{.identifier = Identifier("SomeStruct"),
-                         .fields = {
-                             Field{.identifier = Identifier("public_int"),
-                                   .type = Type{"i32", "int"},
-                                   .access = kPublic},
-                             Field{.identifier = Identifier("protected_int"),
-                                   .type = Type{"i32", "int"},
-                                   .access = kProtected},
-                             Field{.identifier = Identifier("private_int"),
-                                   .type = Type{"i32", "int"},
-                                   .access = kPrivate},
-                         }}}};
+  IR
+      ir =
+          {
+              .used_headers = {HeaderName("foo/bar.h")},
+              .functions = {Func{
+                  .identifier = Identifier("hello_world"),
+                  .mangled_name = "#$mangled_name$#",
+                  .return_type = Type{"i32", "int"},
+                  .params = {FuncParam{Type{"i32", "int"}, Identifier("arg")}},
+                  .is_inline = false}},
+              .records = {Record{.identifier = Identifier("SomeStruct"),
+                                 .fields =
+                                     {
+                                         Field{.identifier =
+                                                   Identifier("public_int"),
+                                               .type = Type{"i32", "int"},
+                                               .access = kPublic,
+                                               .offset = 0},
+                                         Field{.identifier = Identifier(
+                                                   "protected_int"),
+                                               .type = Type{"i32", "int"},
+                                               .access = kProtected,
+                                               .offset = 32},
+                                         Field{.identifier = Identifier(
+                                                   "private_int"),
+                                               .type = Type{"i32", "int"},
+                                               .access = kPrivate,
+                                               .offset = 64},
+                                     },
+                                 .size = 12,
+                                 .alignment = 4}}};
   EXPECT_EQ(ir.ToJson(), expected);
 }
 
diff --git a/rs_bindings_from_cc/src_code_gen.rs b/rs_bindings_from_cc/src_code_gen.rs
index aa32e70..73aa68d 100644
--- a/rs_bindings_from_cc/src_code_gen.rs
+++ b/rs_bindings_from_cc/src_code_gen.rs
@@ -421,6 +421,7 @@
                             type_params: vec![],
                         },
                         access: AccessSpecifier::Public,
+                        offset: 0,
                     },
                     Field {
                         identifier: Identifier { identifier: "protected_int".to_string() },
@@ -431,6 +432,7 @@
                             type_params: vec![],
                         },
                         access: AccessSpecifier::Protected,
+                        offset: 32,
                     },
                     Field {
                         identifier: Identifier { identifier: "private_int".to_string() },
@@ -441,8 +443,11 @@
                             type_params: vec![],
                         },
                         access: AccessSpecifier::Private,
+                        offset: 64,
                     },
                 ],
+                size: 12,
+                alignment: 4,
             }],
             functions: vec![],
         };