mbed
Embed and transform assets into your Rust crate.
about
mbed provides macros for turning files and generated outputs into Artifact
values. Artifacts carry their bytes, MIME type, and Id, and can be grouped
into a Manifest for lookup by identifier.
Basic usage
Requires the macros feature.
pub const LOGO: = include_bytes!;
pub const INDEX: = include_str!;
let id = LOGO.id;
assert_eq!;
Collections and manifests
collect! groups artifacts inside a module. manifest! can then reference
individual artifacts or whole collections with ::*.
Requires the macros feature.
pub const ASSETS: Manifest = manifest!;
let artifact = ASSETS.get.unwrap;
assert_eq!;
Images
Requires the image feature.
pub const LOGO: = include! ;
assert_eq!;
let bytes = LOGO.as_bytes;
JavaScript bundles
Requires the bundle feature.
pub const APP: = bundle!;
let code = APP.code;
let sourcemap = APP.sourcemap;
Tailwind CSS
Requires the tailwindcss feature.
pub const STYLES: = tailwindcss!;
Feature flags
macrosenablesinclude_bytes!,include_str!,collect!, andmanifest!.imageenablesimage:include!and image metadata support.bundleenablesjs:bundle!.tailwindcssenablescss:tailwindcss!.serdeenables serialization support for public data types.cargo-progressshows bundling progress in Cargo build output. This feature is only supported on Linux.
License
mbed is licensed under the MIT License. See LICENSE for details.
Contributing
Contributions are welcome.
Please follow the existing code style and conventions used throughout the project. If you're proposing a new feature or API, opening an issue first is often the easiest way to discuss the design.