23 releases

0.0.21 Dec 2, 2024
0.0.20 Nov 27, 2024
0.0.13 Oct 21, 2024
0.0.8 Sep 10, 2024
0.0.1-a Jul 30, 2024

#745 in Development tools

Download history 225/week @ 2024-08-19 305/week @ 2024-09-02 90/week @ 2024-09-09 38/week @ 2024-09-16 151/week @ 2024-09-30 13/week @ 2024-10-07 149/week @ 2024-10-14 418/week @ 2024-10-21 195/week @ 2024-10-28 156/week @ 2024-11-04 111/week @ 2024-11-11 152/week @ 2024-11-18 268/week @ 2024-11-25 160/week @ 2024-12-02

699 downloads per month

GPL-3.0-or-later

180KB

Ronky - A simple way to export Rust definitions to other languages

Crates.io Version

Example

There is still a lot of work to be done, but here is a simple example of what I have in mind.

The following code and it's output:

#[derive(Export)]
struct Human {
    name: String,
    age: u32,
    friends: Vec<Human>,
    pets: Vec<Pet>,
}

#[derive(Export)]
struct Pet {
    name: String,
    species: String,
}

Which results in the following JSON:

{
  "types": [
    {
      "name": "Human",
      "fields": [
        {
          "name": "name",
          "type": "String"
        },
        {
          "name": "age",
          "type": "u32"
        },
        {
          "name": "friends",
          "type": "list"
          "of": ["Human"],
        },
        {
          "name": "pets",
          "type": "list"
          "of": ["Pet"],
        }
      ]
    },
    {
      "name": "Pet",
      "fields": [
        {
          "name": "name",
          "type": "String"
        },
        {
          "name": "species",
          "type": "String"
        }
      ]
    }
  ]
}

That can then be converted to the following typescript (any supported language, or create your own):

interface Human {
  name: string;
  age: number;
  friends: Human[];
  pets: Pet[];
}

interface Pet {
  name: string;
  species: string;
}

In memory of Ronky

In loving memory of my dear cat Ronky, named for his unique habit of spinning with a loud sound (to "ronk" in Dutch). Ronky lived to the age of 14 and bravely endured acromegaly. This condition resulted in the abnormal growth of his tissues and bones.

He passed away peacefully, surrounded by those who loved him. He will be deeply missed.

Beautiful picture of Ronky

Photo by Startshot

Dependencies

~0.7–1.6MB
~34K SLoC