Crate go_away[][src]

Expand description

Go Away

Go Away is a small library for generating go types & marshalling code from Rust type definitions. It’s intended for use when you have existing rust code that is using serde for JSON serialization and you want to allow go services or clients to interact with that code.

It may be expanded to other languages at some point but it’s mostly been built to service a very specific need and might never evolve past that.

Use is fairly simple:

use go_away::TypeMetadata;

// First, derive TypeMetadata on some types:

#[derive(TypeMetadata)]
struct MyType {
    my_field: String
}

// Then you can register this type inside a `TypeRegistry`

let mut registry = TypeRegistry::new();
MyType::metadata(&mut registy);

// And get some go code to write out to a file:
let go_code = go_away::registry_to_output(registry);

Note that the output go code does not contain any package definitions or required imports. It’s expected that any code that calls go-away will add this for itself.

Modules

types

Defines the type model for go-away - a set of structs that describe types and can be used to generate copies of them in other languages.

Structs

TypeRegistry

A registry of type details.

Traits

TypeMetadata

Exposes metadata about a type that can be used to generate other versions of that type in other languages.

Functions

registry_to_output

Generates go ocde for all the types in the TypeRegistry

Derive Macros

TypeMetadata

Derives TypeMetadata for a given struct.