Crate include_url_macro

Source
Expand description

A procedural macro crate for including URL content as static strings at compile time.

This crate provides two main macros:

§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.