borsh-schema-writer

This library provides a function to take a Struct with the BorshSchema trait and writes the schema to a specified file. This file can then be hosted in a registry, file system, database, web storage, etc... for consumers to use. Here is an example:

```rust use std::fs::File; use std::io::BufReader; use borsh::{BorshDeserialize, BorshSerialize, BorshSchema}; use borsh::schema::{BorshSchemaContainer, Definition, Fields}; use borshschemawriter::schemawriter::writeschema;

[derive(Debug, Default, BorshSerialize, BorshDeserialize, BorshSchema)]

pub struct Person { firstname: String, lastname: String }

fn writeschemaexample() { writeschema(Person::default(), "./tests/schema/personschema.dat".tostring()); let file = File::open("./tests/schema/personschema.dat").unwrap(); let mut reader = BufReader::new(file); let containerfromfile = BorshSchemaContainer::deserialize_reader(&mut reader).expect("Deserialization for BorshSchemaContainer failed"); } ```