Attribute Macro typeshare::typeshare

source ·
#[typeshare]
Expand description

Marks a type as a type shared across the FFI boundary using typeshare.

The typeshare program will process all the types with this attribute. It will ignore all types that do not have this attribute.

Example

 use typeshare::typeshare;

 #[typeshare]
 pub struct Person {
     name: String,
     email: String,
 }

If the file above is src/person.rs, then typeshare --lang=typescript src/person.rs would generate the typescript bindings for the Person type.

Ignoring enum variants

If you don’t want to typeshare a certain enum variant, just put a #[typeshare(skip)] attribute on that variant.

use typeshare::typeshare;

#[typeshare]
pub enum SomeEnum {
    A,
    #[typeshare(skip)]
    B, // <- this variant will not be included in the typeshared file(s)
    C,
}