cream_core/
macros.rs

1/// Declare a schema with a given name and id.
2#[macro_export]
3macro_rules! declare_schema {
4    ($name:ident = $id:literal) => {
5        #[derive(derive_more::Display, Default, Debug, Copy, Clone)]
6        #[display($id)]
7        pub struct $name;
8
9        serde_plain::derive_serialize_from_display!($name);
10    };
11}
12
13/// Declare a resource type with a given name and id.
14#[macro_export]
15macro_rules! declare_resource_type {
16    ($name:ident = $id:literal) => {
17        #[derive(derive_more::Display, Default, Debug, Copy, Clone)]
18        #[display($id)]
19        pub struct $name;
20
21        serde_plain::derive_serialize_from_display!($name);
22    };
23}
24
25/// Load a JSON file from the `include_str!` macro.
26#[macro_export]
27macro_rules! load_static_json {
28    ($path:literal) => {
29        ::serde_json::from_str(include_str!($path)).expect(concat!("Failed to deserialize ", $path))
30    };
31}