postcard-bindgen 0.1.3

A crate to generate bindings for the postcard binary format for other languages than Rust.
docs.rs failed to build postcard-bindgen-0.1.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: postcard-bindgen-0.7.1

Postcard Bindgen

This crate allows generating javascript bindings automatically to serialize javascript objects to postcard format and vice versa.

Example

This example shows how to generate a npm package out of the rust structures. A new folder with the package name will be created. A javascript file and typescript typings as well as a package.json will be paced in it.

# use postcard_bindgen::{PostcardBindings, generate_bindings, build_npm_package, PackageInfo};
# use serde::Serialize;
# extern crate alloc;
#[derive(Serialize, PostcardBindings)]
struct A(u8);

#[derive(Serialize, PostcardBindings)]
struct B {
a: u8
}

#[derive(Serialize, PostcardBindings)]
enum C {
A,
B(u8),
C(A, B),
D { a: &'static str, b: B },
}

fn main() {
build_npm_package(
std::env::current_dir().unwrap().as_path(),
PackageInfo {
name: "test-bindings".into(),
version: "0.1.0".try_into().unwrap(),
},
generate_bindings!(A, B),
)
.unwrap();
}
// JavaScript
import { serialize } form "test-bindings"

const c = {
tag: "C",
value: [
123,
{
a: 234
}
]
}

const bytes = serialize("C", c)