This PR works on adding implementation of WriteToIsl which serializes a schema model into a schema file using Ion writer.
Example:
Here is a quick example of how to serialize a schema model using Ion writer.
// construct an ISL type programmatically
let isl_type = named_type(
// represents the `name` of the defined type
"my_number_type".to_owned(),
vec![
// represents `one_of` constraint
one_of(vec![
named_type_ref("int"),
named_type_ref("float"),
named_type_ref("decimal"),
]),
],
);
// create an ISL schema using above `isl_type`
let isl_schema = IslSchema::schema_v_1_0(
"my_schema.isl", // represents schem id which is usually same as the schema file name
vec![], // represents imports
vec![isl_type.to_owned()],
vec![], // represents inline imports
vec![], // represents open content
);
// use an Ion Writer to write the ISL model
let mut buffer = Vec::new();
let mut writer = TextWriterBuilder::pretty().build(&mut buffer)?;
isl_schema.write_to(&mut writer)?;
// write into schema file
let mut file = File::create("my_schema.isl")?;
file.write_all(writer.output().as_bytes())?;
Issue #173
Description of changes:
This PR works on adding implementation of
WriteToIsl
which serializes a schema model into a schema file using Ion writer.Example:
Here is a quick example of how to serialize a schema model using Ion writer.
Output:
List of changes:
WriteToIsl
to serialize isl model into schema fileWriteToIsl
trait which will be sued by all ISL model structs to write schema content to an Ion writerWriteToIsl
forIslSchema
WriteToIsl
implementation forUserReservedFields
Test:
Adds unit tests for
WriteToIsl
implementations.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.