Crate gull[−][src]
Gull
is a tool that can generate static type definitions for multiple
languages.
Given an abstract definitions of types it can generate source code containing these type definitions in multiple languages.
Although different languages might have different support for types (e.g. PHP or JS don't support Rust enums) the assumption is made that they both serialize to the same JSON object and can be deserialized safely.
This crate is focuse on generating developer friendly types that can be used in the code directly. It does not intend to solve RPC problems like other frameworks like Thrift or gRPC are trying to solve (e.g gull does nothing to make sure types a backward compatible)
Example:
use gull::prelude::*; let mut declarations = Declarations::new(); declarations.add(TypeDeclaration { name: "Frame", docs: "Frame represents a tuple of an Timestamp (RFC3339) and an ID", config: vec![TypeDeclarationConfig::RustAttribute("#[derive(Copy)]")], value: DeclarationValue::TTuple(TTuple { items: vec![ TupleItem::TPrimitive(TPrimitive::String), TupleItem::TPrimitive(TPrimitive::Ti64), ], }), }); assert_eq!( declarations.codegen_rust().unwrap(), " #[derive(Copy)] /// Frame represents a tuple of an Timestamp (RFC3339) and an ID pub type Frame = (String, i64); " );
for more examples see gull/e2e/basic_codegen_test.rs
Re-exports
pub use generator::write_generated; |
Modules
generator | |
prelude | |
sign_source |