Expand description
A procedural macro crate for including URL content as static strings at compile time.
This crate provides two main macros:
include_url!for including raw content from URLsinclude_json_url!for including and parsing JSON content from URLs
§Examples
Basic usage with text content:
use include_url_macro::include_url;
const CONTENT: &str = include_url!("https://example.com/static/content.txt");Including JSON content with type inference:
use include_url_macro::include_json_url;
use serde::Deserialize;
#[derive(Deserialize)]
struct Post {
userId: i32,
id: i32,
title: String,
body: String,
}
let post: Post = include_json_url!("https://jsonplaceholder.typicode.com/posts/1", Post);Macros§
- include_
json_ url - A procedural macro that includes and parses JSON content from a URL at compile time.
- include_
url - A procedural macro that includes content from a URL as a static string at compile time.