5 stable releases
new 1.3.0 | May 8, 2025 |
---|---|
1.2.1 | Apr 22, 2025 |
1.1.2 | Apr 15, 2025 |
1.1.0 | Apr 14, 2025 |
1.0.0 |
|
#277 in Hardware support
452 downloads per month
Used in typeshare-java
180KB
4K
SLoC
typeshare-driver
This crate contains a macro generating all the glue code necessary to create a typeshare binary. Supposing you had your own Python and Golang implementations of typeshare, all you need to write is this:
use typeshare_driver::typeshare_binary;
use typeshare_golang::Golang;
use typeshare_python::Python;
typeshare_binary! { Python, Golang }
This creates an fn main
that uses these languages, plus typeshare-engine
, to implements a full typeshare CLI.
lib.rs
:
Framework for creating a typeshare binary.
This library provides a macro that creates a fn main
that implements an
entire typeshare binary, using only the Language
implementations that you provide.
The macro is very simple. Supposing that you have implementations of Language
called Kotlin
and Swift
, call the macro like this:
use std::marker::PhantomData;
use typeshare_driver::typeshare_binary;
struct Kotlin {}
// impl<'config> Language<'config> for Kotlin { ... }
struct Swift<'c> {
config: PhantomData<&'config str>;
}
// impl<'config> Language<'config> for Swift<'config> { ... }
typeshare_binary! { Kotlin, Swift<'config> }
This creates an fn main
that uses the functionality in [typeshare-engine][typeshare_engine]
to create a complete, working typeshare binary. That binary will include a
complete command-line interface, populated with global options like --config
and --lang
, as well as language-specific options like --kotlin-package
;
these language-specific flags are determined automatically based on the
Config
type provided by each Language
implementation. Use --help
for a complete
description of all CLI options.
See the typeshare_model::Language
docs for details on how to create a specific language implementation.
See the [typeshare-engine][typeshare_engine] docs if you want to use typeshare
as a library instead of a binary program; it contains all of the actual logic
for running typeshare. typeshare-driver just bootstraps the functionality
in the engine into a working main
.
Dependencies
~6–15MB
~190K SLoC