postcard_schema

Derive Macro Schema

Source
#[derive(Schema)]
{
    // Attributes available to this derive:
    #[postcard]
}
Expand description

Derive Schema for a struct or enum

§Examples

use postcard_schema::Schema;

#[derive(Schema)]
struct Point {
    x: i32,
    y: i32,
}

§Attributes

§#[postcard(crate = ...)]

The #[postcard(crate = ...)] attribute can be used to specify a path to the postcard_schema crate instance to use when referring to Schema and schema types from generated code. This is normally only applicable when invoking re-exported derives from a different crate.

use postcard_schema as reexported_postcard_schema;

#[derive(Schema)]
#[postcard(crate = reexported_postcard_schema)]
struct Point {
    x: i32,
    y: i32,
}

Derive the postcard_schema::Schema trait for a struct or enum.