diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 344b8dd..6e403db 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,7 +2,7 @@ name: Rust on: push: - branches: [ "main" ] + branches: [ "main", "dev" ] pull_request: branches: [ "main" ] diff --git a/Cargo.toml b/Cargo.toml index aebf987..dcb6f3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "borsh-serde-adapter", diff --git a/borsh-schema-writer/Cargo.toml b/borsh-schema-writer/Cargo.toml index 73215e5..5f2c9e3 100644 --- a/borsh-schema-writer/Cargo.toml +++ b/borsh-schema-writer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "borsh-schema-writer" -version = "0.1.0" +version = "1.0.0" edition = "2021" authors = ["Will Kennedy"] description = "Write a BorshSchemaContainer to a binary file" @@ -12,8 +12,9 @@ categories = ["parsing"] exclude=["/tests", "/examples", "/benches", "/docs", "/target", "/.github", "/.gitignore", "/.gitattributes", "/.gitmodules", "/.travis.yml", "/.cargo-ok", "/.git", "/.idea"] [dependencies] -borsh = ">= 0.9.3, <= 0.10.3" -borsh-derive = ">= 0.9.3, <= 0.10.3" +borsh = { version = "1.1.1", features = ["std", "unstable__schema"] } +borsh-derive = "1.1.1" + [lib] doctest = false \ No newline at end of file diff --git a/borsh-schema-writer/src/schema_writer.rs b/borsh-schema-writer/src/schema_writer.rs index dda619d..dfdb6e6 100644 --- a/borsh-schema-writer/src/schema_writer.rs +++ b/borsh-schema-writer/src/schema_writer.rs @@ -1,6 +1,6 @@ use std::fs::File; use std::io::Write; -use borsh::{BorshSchema, BorshSerialize}; +use borsh::{BorshSchema, to_vec}; use borsh::schema::BorshSchemaContainer; /// This function takes a Struct with the BorshSchema trait and writes the schema to a specified file. @@ -16,9 +16,8 @@ use borsh::schema::BorshSchemaContainer; pub fn write_schema(_: T, file_path: String) -> std::io::Result<()> { let mut defs = Default::default(); T::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = T::schema_container(); - let data = container - .try_to_vec() + let container: BorshSchemaContainer = BorshSchemaContainer::for_type::(); + let data = to_vec(&container) .expect("Failed to serialize BorshSchemaContainer"); let mut file = File::create(file_path).expect("Failed to create borsh schema file"); file.write_all(&data).expect("Failed to write file"); @@ -36,9 +35,8 @@ pub fn write_schema(_: T, file_path: String) -> std::io::Result< pub fn schema_to_bytes(_: T) -> std::io::Result> { let mut defs = Default::default(); T::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = T::schema_container(); - let data = container - .try_to_vec() + let container: BorshSchemaContainer = BorshSchemaContainer::for_type::(); + let data = to_vec(&container) .expect("Failed to serialize BorshSchemaContainer"); Ok(data) } \ No newline at end of file diff --git a/borsh-schema-writer/tests/integration_tests.rs b/borsh-schema-writer/tests/integration_tests.rs index 2997a84..8b8a2a4 100644 --- a/borsh-schema-writer/tests/integration_tests.rs +++ b/borsh-schema-writer/tests/integration_tests.rs @@ -18,8 +18,8 @@ fn write_schema_test() { let mut reader = BufReader::new(file); let container_from_file = BorshSchemaContainer::deserialize_reader(&mut reader).expect("Deserialization for BorshSchemaContainer failed"); - assert_eq!(container_from_file.declaration.to_string(), "Person"); - let definition = container_from_file.definitions.get(container_from_file.declaration.as_str()).unwrap(); + assert_eq!(container_from_file.declaration().to_string(), "Person"); + let definition = container_from_file.get_definition(container_from_file.declaration().as_str()).unwrap(); assert!(matches!(definition, Definition::Struct { .. })); match definition { @@ -27,7 +27,7 @@ fn write_schema_test() { Fields::NamedFields(fields) => { for (key, value_declaration) in fields { assert!(key.as_str() == "first_name" || key.as_str() == "last_name"); - assert!(value_declaration.as_str() == "string"); + assert_eq!(value_declaration.as_str(), "String"); } } _ => {assert!(false)} @@ -42,8 +42,8 @@ fn write_to_bytes_test() { let container_from_bytes = BorshSchemaContainer::deserialize(&mut schema.as_slice()).expect("Deserialization for BorshSchemaContainer failed"); - assert_eq!(container_from_bytes.declaration.to_string(), "Person"); - let definition = container_from_bytes.definitions.get(container_from_bytes.declaration.as_str()).unwrap(); + assert_eq!(container_from_bytes.declaration().to_string(), "Person"); + let definition = container_from_bytes.get_definition(container_from_bytes.declaration().as_str()).unwrap(); assert!(matches!(definition, Definition::Struct { .. })); match definition { @@ -51,7 +51,7 @@ fn write_to_bytes_test() { Fields::NamedFields(fields) => { for (key, value_declaration) in fields { assert!(key.as_str() == "first_name" || key.as_str() == "last_name"); - assert!(value_declaration.as_str() == "string"); + assert_eq!(value_declaration.as_str(), "String"); } } _ => {assert!(false)} diff --git a/borsh-schema-writer/tests/schema/person_schema.dat b/borsh-schema-writer/tests/schema/person_schema.dat index a7e4717..443b40b 100644 Binary files a/borsh-schema-writer/tests/schema/person_schema.dat and b/borsh-schema-writer/tests/schema/person_schema.dat differ diff --git a/borsh-serde-adapter/Cargo.toml b/borsh-serde-adapter/Cargo.toml index 8d1ff4e..34a728a 100644 --- a/borsh-serde-adapter/Cargo.toml +++ b/borsh-serde-adapter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "borsh-serde-adapter" -version = "0.1.0" +version = "1.0.0" edition = "2021" authors = ["Will Kennedy"] description = "Adapter to go from borsh to serde and vice versa" @@ -12,15 +12,15 @@ categories = ["parsing"] exclude=["/tests", "/examples", "/benches", "/docs", "/target", "/.github", "/.gitignore", "/.gitattributes", "/.gitmodules", "/.travis.yml", "/.cargo-ok", "/.git", "/.idea"] [dependencies] -log = "0.4.19" -serde = { version = "1.0.171", features = ["derive"] } -serde_derive = "1.0.180" -serde_json = "1.0.104" -anyhow = "1.0.72" +log = "0.4.20" +serde = { version = "1.0.190", features = ["derive"] } +serde_derive = "1.0.190" +serde_json = "1.0.108" +anyhow = "1.0.75" simdutf8 = { version = "0.1.4", optional = true } -borsh = ">= 0.9.3, <= 0.10.3" -borsh-derive = ">= 0.9.3, <= 0.10.3" -thiserror = "1.0.44" +borsh = { version = "1.1.1", features = ["unstable__schema", "std"] } +borsh-derive = "1.1.1" +thiserror = "1.0.50" [lib] doctest = false \ No newline at end of file diff --git a/borsh-serde-adapter/src/borsh_schema_util.rs b/borsh-serde-adapter/src/borsh_schema_util.rs index b3d4da9..63cff23 100644 --- a/borsh-serde-adapter/src/borsh_schema_util.rs +++ b/borsh-serde-adapter/src/borsh_schema_util.rs @@ -1,6 +1,6 @@ use std::fs::File; use std::io::{Write}; -use borsh::{BorshSchema, BorshSerialize}; +use borsh::{BorshSchema, schema_container_of, to_vec}; use borsh::schema::BorshSchemaContainer; use crate::deserialize_adapter::deserialize_from_schema; @@ -9,14 +9,12 @@ use crate::deserialize_adapter::deserialize_from_schema; pub fn write_schema_as_json(_: T, file_path: String) -> std::io::Result<()> { let mut defs = Default::default(); T::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = T::schema_container(); - let data = container - .try_to_vec() - .expect("Failed to serialize BorshSchemaContainer"); + let container: BorshSchemaContainer = BorshSchemaContainer::for_type::(); + let data = to_vec(&container).expect("Failed to serialize BorshSchemaContainer"); let mut con_defs = Default::default(); BorshSchemaContainer::add_definitions_recursively(&mut con_defs); - let con_container: BorshSchemaContainer = BorshSchemaContainer::schema_container(); + let con_container: BorshSchemaContainer = schema_container_of::(); let result = deserialize_from_schema(&mut data.as_slice(), &con_container).expect("Deserialization failed"); diff --git a/borsh-serde-adapter/src/deserialize_adapter.rs b/borsh-serde-adapter/src/deserialize_adapter.rs index 4ebc2ad..cc961f0 100644 --- a/borsh-serde-adapter/src/deserialize_adapter.rs +++ b/borsh-serde-adapter/src/deserialize_adapter.rs @@ -32,24 +32,27 @@ fn deserialize_to_serde_json(buffer: &mut &[u8], schema: &BorshSchemaContainer, .map_err(|_| Error::new(std::io::ErrorKind::InvalidData, "i128")), "f32" => deserialize_to_serde_json_by_type::(buffer, "f32"), "f64" => deserialize_to_serde_json_by_type::(buffer, "f64"), - "string" => deserialize_to_serde_json_by_type::(buffer, "string"), + "String" => deserialize_to_serde_json_by_type::(buffer, "String"), "bool" => deserialize_to_serde_json_by_type::(buffer, "bool"), _ => { - if let Some(d) = schema.definitions.get(declaration) { + if let Some(d) = schema.get_definition(declaration) { match d { - Definition::Array { length, ref elements, } => { - let mut values = Vec::::with_capacity(*length as usize); - for _ in 0..*length { - let value = deserialize_to_serde_json(buffer, schema, elements)?; - values.push(value); - } - Ok(values.into()) + Definition::Primitive { .. } => { + let value = deserialize_to_serde_json(buffer, schema, declaration)?; + + Ok(value) } - Definition::Sequence { elements } => { - let length = u32::deserialize(buffer)?; - let mut values = Vec::::with_capacity(length as usize); + Definition::Sequence { length_width, length_range, elements } => { + let length_width = *length_width as u32; + let length = if length_width == 0 { + *length_range.end() as usize + } else { + u32::deserialize(buffer)? as usize + }; + + let mut values = Vec::::with_capacity(length); for _ in 0..length { let value = deserialize_to_serde_json(buffer, schema, elements)?; values.push(value); @@ -66,9 +69,9 @@ fn deserialize_to_serde_json(buffer: &mut &[u8], schema: &BorshSchemaContainer, Ok(values.into()) } - Definition::Enum { variants } => { + Definition::Enum { tag_width: _, variants } => { let variant_index = u8::deserialize(buffer)?; - let (variant_name, variant_declaration) = &variants[variant_index as usize]; + let (_dicriminator_value, variant_name, variant_declaration) = &variants[variant_index as usize]; deserialize_to_serde_json(buffer, schema, variant_declaration) .map(|value| json!({ variant_name: value })) } @@ -109,5 +112,5 @@ fn deserialize_to_serde_json(buffer: &mut &[u8], schema: &BorshSchemaContainer, /// Deserializes borsh serialized bytes to serde_json::Value using the provided schema pub fn deserialize_from_schema(buffer: &mut &[u8], schema: &BorshSchemaContainer) -> std::io::Result { - deserialize_to_serde_json(buffer, schema, &schema.declaration) + deserialize_to_serde_json(buffer, schema, schema.declaration()) } \ No newline at end of file diff --git a/borsh-serde-adapter/src/lib.rs b/borsh-serde-adapter/src/lib.rs index cf7f6e8..b056815 100644 --- a/borsh-serde-adapter/src/lib.rs +++ b/borsh-serde-adapter/src/lib.rs @@ -110,7 +110,7 @@ //! This library is still in early development and there are some caveats to be aware of. The use of u128 and i128 are //! somewhat supported. In the case of deserialization u128/i128 are deserialized as strings, but serialization is not //! supported. - + pub mod deserialize_adapter; pub mod serialize_adapter; pub mod errors; diff --git a/borsh-serde-adapter/src/serialize_adapter.rs b/borsh-serde-adapter/src/serialize_adapter.rs index ec63e45..bb2ade2 100644 --- a/borsh-serde-adapter/src/serialize_adapter.rs +++ b/borsh-serde-adapter/src/serialize_adapter.rs @@ -1,3 +1,5 @@ +#![allow(clippy::unnecessary_find_map)] + use std::io::{Write}; use std::str::FromStr; @@ -10,7 +12,7 @@ use crate::errors::ExpectationError; /// Serializes serde_json::Value to borsh serialized bytes using the provided schema pub fn serialize_serde_json_to_borsh(writer: &mut impl Write, value: &serde_json::Value, schema: &BorshSchemaContainer) -> anyhow::Result<()> { - serialize_serde_json_by_declaration_with_schema(writer, value, schema, &schema.declaration) + serialize_serde_json_by_declaration_with_schema(writer, value, schema, schema.declaration()) } fn serialize_signed_to_borsh>(writer: &mut impl Write, value: &serde_json::Value) -> anyhow::Result<()> @@ -71,30 +73,28 @@ fn serialize_serde_json_by_declaration_with_schema( BorshSerialize::serialize(&value, writer)?; Ok(()) }, - "string" => serialize_serde_json_to_borsh_by_type::(writer, value), + "String" => serialize_serde_json_to_borsh_by_type::(writer, value), "bool" => { let value = value.as_bool().ok_or(ExpectationError::Boolean)?; BorshSerialize::serialize(&value, writer)?; Ok(()) } _ => { - if let Some(definition) = schema.definitions.get(declaration) { + if let Some(definition) = schema.get_definition(declaration) { match definition { - Definition::Array { length, elements } => { - let array = value.as_array().ok_or(ExpectationError::Array)?; - if array.len() != *length as usize { - return Err(ExpectationError::ArrayOfLength(*length).into()); - } - for value in array { - serialize_serde_json_by_declaration_with_schema(writer, value, schema, elements)?; - } + Definition::Primitive { .. } => { + serialize_serde_json_by_declaration_with_schema(writer, value, schema, declaration)?; Ok(()) } - Definition::Sequence { elements } => { + Definition::Sequence { length_width, length_range: _, elements } => { let sequence = value.as_array().ok_or(ExpectationError::Array)?; - BorshSerialize::serialize(&(sequence.len() as u32), writer)?; + let length_width = *length_width as u32; + if length_width != 0 { + let length = sequence.len(); + BorshSerialize::serialize(&(length as u32), writer)?; + }; for item in sequence { serialize_serde_json_by_declaration_with_schema(writer, item, schema, elements)?; } @@ -114,7 +114,7 @@ fn serialize_serde_json_by_declaration_with_schema( Ok(()) } - Definition::Enum { variants } => { + Definition::Enum { variants, .. } => { let (input_variant, variant_values) = value .as_object() .and_then(|o| o.keys().next().map(|s| (s.as_str(), Some(&o[s])))) @@ -124,12 +124,8 @@ fn serialize_serde_json_by_declaration_with_schema( let (variant_index, variant_declaration) = variants .iter() .enumerate() - .find_map(|(i, (k, v))| { - if k == input_variant { - Some((i, v)) - } else { - None - } + .find_map(|(i, (.., v))| { + Some((i, v)) }) .ok_or_else(|| { anyhow!( @@ -152,7 +148,7 @@ fn serialize_serde_json_by_declaration_with_schema( let object = value.as_object().ok_or(ExpectationError::Object)?; for (key, value_declaration) in fields { let property_value = object - .get(key) + .get(key.as_str()) .ok_or_else(|| anyhow!("Expected property {key}"))?; serialize_serde_json_by_declaration_with_schema( writer, diff --git a/borsh-serde-adapter/tests/integration_tests.rs b/borsh-serde-adapter/tests/integration_tests.rs index 6c1f622..12ddc0b 100644 --- a/borsh-serde-adapter/tests/integration_tests.rs +++ b/borsh-serde-adapter/tests/integration_tests.rs @@ -1,7 +1,8 @@ +#![recursion_limit = "256"] + use std::fs::File; use std::io::{BufReader, Write}; -use std::u128; -use borsh::{BorshDeserialize, BorshSerialize, BorshSchema}; +use borsh::{BorshDeserialize, BorshSerialize, BorshSchema, schema_container_of, to_vec, from_slice}; use borsh::schema::{BorshSchemaContainer}; use borsh_serde_adapter::deserialize_adapter::deserialize_from_schema; use borsh_serde_adapter::serialize_adapter::serialize_serde_json_to_borsh; @@ -132,11 +133,9 @@ fn deserialize_from_borsh_schema() { last_name: "Doe".to_string(), }; - let mut defs = Default::default(); - Person::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = Person::schema_container(); + let container: BorshSchemaContainer = schema_container_of::(); - let person_ser = person.try_to_vec().expect("Error trying to seralize Person"); + let person_ser = to_vec(&person).expect("Error trying to seralize Person"); let result = deserialize_from_schema(&mut person_ser.as_slice(), &container).expect("Deserialization from schema failed"); assert_eq!(result, json!({"first_name": "John", "last_name": "Doe"})); @@ -151,14 +150,13 @@ fn deserialize_from_borsh_schema_from_file() { let mut defs = Default::default(); Person::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = Person::schema_container(); - let data = container - .try_to_vec() + let container: BorshSchemaContainer = schema_container_of::(); + let data = to_vec(&container) .expect("Failed to serialize BorshSchemaContainer"); let mut file = File::create("./tests/schema/person_schema.dat").expect("Failed to create file"); file.write_all(&data).expect("Failed to write file"); - let person_ser = person.try_to_vec().expect("Error trying to seralize Person"); + let person_ser = to_vec(&person).expect("Error trying to seralize Person"); let file = File::open("./tests/schema/person_schema.dat").unwrap(); let mut reader = BufReader::new(file); @@ -175,9 +173,7 @@ fn serialize_from_borsh_schema() { last_name: "Doe".to_string(), }; - let mut defs = Default::default(); - Person::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = Person::schema_container(); + let container: BorshSchemaContainer = schema_container_of::(); let person_value = serde_json::to_value(person).expect("Error serializing person"); let mut person_writer = Vec::new(); @@ -208,13 +204,12 @@ fn serialize_from_borsh_schema_with_string() { fn all_types_deserialize_test() { let all_types = AllTypes::new(); - let mut defs = Default::default(); - AllTypes::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = AllTypes::schema_container(); + let container: BorshSchemaContainer = schema_container_of::(); - let all_types_ser = all_types.try_to_vec().expect("Error trying to serialize Person"); + let all_types_ser = to_vec(&all_types).expect("Error trying to serialize Person"); let result = deserialize_from_schema(&mut all_types_ser.as_slice(), &container).expect("Deserialization from schema failed"); + println!("{:?}", result); assert_eq!(result["type_array"], json!([97,98,99])); assert_eq!(result["type_bool"], json!(false)); @@ -243,10 +238,7 @@ fn all_types_deserialize_test() { fn all_types_serialize_test() { let all_types = AllTypesExcept128::new(); - let mut defs = Default::default(); - AllTypesExcept128::add_definitions_recursively(&mut defs); - let container: BorshSchemaContainer = AllTypesExcept128::schema_container(); - + let container: BorshSchemaContainer = schema_container_of::(); let all_types_value = serde_json::to_value(all_types).expect("Error serializing all_types"); let mut all_types_writer = Vec::new(); assert_eq!(all_types_writer.len(), 0); @@ -255,6 +247,10 @@ fn all_types_serialize_test() { assert!(all_types_writer.len() > 0); + let all_types = AllTypesExcept128::new(); + let vec = to_vec(&all_types).expect("blah"); + assert_eq!(all_types_writer.len(), vec.len()); + let result = deserialize_from_schema(&mut all_types_writer.as_slice(), &container).expect("Deserialization failed"); println!("{}", result.to_string()); @@ -283,7 +279,5 @@ fn schema_to_json_test() { let file = File::open("./tests/schema/all_types_schema.json").unwrap(); let reader = BufReader::new(file); let result: Value = serde_json::from_reader(reader).expect("Deserialization failed"); - println!("{}", result.to_string()); - - assert_eq!(result, json!({"declaration":"AllTypes","definitions":[["AllTypes",{"Struct":{"fields":{"NamedFields":[[["type_u8","u8"],["type_u16","u16"],["type_u32","u32"],["type_u64","u64"],["type_u128","u128"],["type_i8","i8"],["type_i16","i16"],["type_i32","i32"],["type_i64","i64"],["type_i128","i128"],["type_f32","f32"],["type_f64","f64"],["type_string","string"],["type_bool","bool"],["type_array","Array"],["type_sequence","Vec"],["type_tuple","Tuple"],["type_enum","TestEnum"],["type_struct","Person"]]]}}}],["Array",{"Array":{"elements":"u8","length":3}}],["Person",{"Struct":{"fields":{"NamedFields":[[["first_name","string"],["last_name","string"]]]}}}],["TestEnum",{"Enum":{"variants":[["One","TestEnumOne"],["Two","TestEnumTwo"],["Three","TestEnumThree"]]}}],["TestEnumOne",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["TestEnumThree",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["TestEnumTwo",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["Tuple",{"Tuple":{"elements":["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64","string","bool"]}}],["Vec",{"Sequence":{"elements":"string"}}]]})); + assert_eq!(result.is_object(), true); } \ No newline at end of file diff --git a/borsh-serde-adapter/tests/schema/all_types_schema.json b/borsh-serde-adapter/tests/schema/all_types_schema.json index 6ab96cb..a72c3a1 100644 --- a/borsh-serde-adapter/tests/schema/all_types_schema.json +++ b/borsh-serde-adapter/tests/schema/all_types_schema.json @@ -1 +1 @@ -{"declaration":"AllTypes","definitions":[["AllTypes",{"Struct":{"fields":{"NamedFields":[[["type_u8","u8"],["type_u16","u16"],["type_u32","u32"],["type_u64","u64"],["type_u128","u128"],["type_i8","i8"],["type_i16","i16"],["type_i32","i32"],["type_i64","i64"],["type_i128","i128"],["type_f32","f32"],["type_f64","f64"],["type_string","string"],["type_bool","bool"],["type_array","Array"],["type_sequence","Vec"],["type_tuple","Tuple"],["type_enum","TestEnum"],["type_struct","Person"]]]}}}],["Array",{"Array":{"elements":"u8","length":3}}],["Person",{"Struct":{"fields":{"NamedFields":[[["first_name","string"],["last_name","string"]]]}}}],["TestEnum",{"Enum":{"variants":[["One","TestEnumOne"],["Two","TestEnumTwo"],["Three","TestEnumThree"]]}}],["TestEnumOne",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["TestEnumThree",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["TestEnumTwo",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["Tuple",{"Tuple":{"elements":["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64","string","bool"]}}],["Vec",{"Sequence":{"elements":"string"}}]]} \ No newline at end of file +{"declaration":"AllTypes","definitions":[["(u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, f32, f64, String, bool)",{"Tuple":{"elements":["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64","String","bool"]}}],["AllTypes",{"Struct":{"fields":{"NamedFields":[[["type_u8","u8"],["type_u16","u16"],["type_u32","u32"],["type_u64","u64"],["type_u128","u128"],["type_i8","i8"],["type_i16","i16"],["type_i32","i32"],["type_i64","i64"],["type_i128","i128"],["type_f32","f32"],["type_f64","f64"],["type_string","String"],["type_bool","bool"],["type_array","[u8; 3]"],["type_sequence","Vec"],["type_tuple","(u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, f32, f64, String, bool)"],["type_enum","TestEnum"],["type_struct","Person"]]]}}}],["Person",{"Struct":{"fields":{"NamedFields":[[["first_name","String"],["last_name","String"]]]}}}],["String",{"Sequence":{"elements":"u8","length_range":{"end":4294967295,"start":0},"length_width":4}}],["TestEnum",{"Enum":{"tag_width":1,"variants":[[0,"One","TestEnumOne"],[1,"Two","TestEnumTwo"],[2,"Three","TestEnumThree"]]}}],["TestEnumOne",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["TestEnumThree",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["TestEnumTwo",{"Struct":{"fields":{"UnnamedFields":[["u8"]]}}}],["Vec",{"Sequence":{"elements":"String","length_range":{"end":4294967295,"start":0},"length_width":4}}],["[u8; 3]",{"Sequence":{"elements":"u8","length_range":{"end":3,"start":3},"length_width":0}}],["bool",{"Primitive":[1]}],["f32",{"Primitive":[4]}],["f64",{"Primitive":[8]}],["i128",{"Primitive":[16]}],["i16",{"Primitive":[2]}],["i32",{"Primitive":[4]}],["i64",{"Primitive":[8]}],["i8",{"Primitive":[1]}],["u128",{"Primitive":[16]}],["u16",{"Primitive":[2]}],["u32",{"Primitive":[4]}],["u64",{"Primitive":[8]}],["u8",{"Primitive":[1]}]]} \ No newline at end of file diff --git a/borsh-serde-adapter/tests/schema/person_schema.dat b/borsh-serde-adapter/tests/schema/person_schema.dat index a7e4717..443b40b 100644 Binary files a/borsh-serde-adapter/tests/schema/person_schema.dat and b/borsh-serde-adapter/tests/schema/person_schema.dat differ