# firebae-derive
Derive macros for [firebae-cm](https://github.com/Vesafary/firebae-cm).
You normally do not depend on this crate directly — `firebae-cm` re-exports
everything here.
## `AsFirebaseMap`
FCM `data`, `headers` and `payload` fields are `map<string, string>`. This macro
implements `IntoFirebaseMap` for a struct with named fields, stringifying each field:
``` rust
use firebae_cm::{AsFirebaseMap, MessageBody, Receiver};
#[derive(AsFirebaseMap)]
struct MessageData {
custom_field: String,
another_type: i32, // becomes "15"
optional_field: Option<String>, // omitted entirely when None
}
let data = MessageData {
custom_field: "Hello, world!".to_string(),
another_type: 15,
optional_field: None,
};
let body = MessageBody::new(Receiver::topic("subscribers"))
.data(data)
.expect("Unable to parse data");
```
Any type implementing `Display` can be used as a field value. `Option<T>` fields are
skipped when `None` rather than serialized as a placeholder.
The generated code resolves `firebae-cm` through `proc-macro-crate`, so renaming the
dependency in your `Cargo.toml` is supported.
## License
MIT