maycoon_macros/lib.rs
1#![warn(missing_docs)]
2
3//! Macros for Maycoon => See `maycoon` crate.
4//!
5//! Contains procedural macros.
6
7mod assets;
8mod svg_icon;
9
10/// Create a new `SvgIcon` from the given SVG source.
11///
12/// This is equivalent to `SvgIcon::new(static_asset!(url))` and works as a convenience macro.
13#[proc_macro]
14pub fn svg_icon(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
15 proc_macro::TokenStream::from(svg_icon::svg_icon(proc_macro2::TokenStream::from(input)))
16}
17
18/// Creates a static asset from the given path/url and caches the file for faster compilation times.
19///
20/// This will either read a file path or download the file from the given URL using [ureq].
21/// After the data has been retrieved, it will be saved as a static asset file in a temporary directory (e.g. `%temp%` on windows).
22/// When re-executing this macro, the file can be re-loaded for faster compilation times.
23#[proc_macro]
24pub fn static_asset(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
25 proc_macro::TokenStream::from(assets::static_asset(proc_macro2::TokenStream::from(input)))
26}