rust_embed_for_web/
lib.rs

1//! Rust Macro which embeds files into your executable. A fork of `rust-embed`
2//! with a focus on usage in web servers.
3//!
4//! Please check out the
5//! [readme](https://github.com/SeriousBug/rust-embed-for-web/blob/master/readme.md)
6//! in the repository to get started. There's an
7//! [example](https://github.com/SeriousBug/rust-embed-for-web/blob/master/examples/actix.rs)
8//! available too!
9//!
10//! If you are using this with Actix Web, there's an existing responder
11//! [`actix-web-rust-embed-responder`](https://lib.rs/crates/actix-web-rust-embed-responder)
12//! which will handle everything for you, from negotiating compressed responses
13//! to cache revalidation.
14#![forbid(unsafe_code)]
15
16#[allow(unused_imports)]
17#[macro_use]
18extern crate rust_embed_for_web_impl;
19
20pub use rust_embed_for_web_impl::*;
21
22pub use rust_embed_for_web_utils::{DynamicFile, EmbedableFile, EmbeddedFile};
23
24#[doc(hidden)]
25pub extern crate rust_embed_for_web_utils as utils;
26
27/// A folder of embedded files.
28///
29/// The type of the file `RustEmbed::File` depends on whether we're in debug
30/// mode or release mode:
31///
32/// - In debug mode it will be a `DynamicFile`
33/// - In release mode it will be a `EmbeddedFile`
34///
35/// The derivation will automatically generate the correct file type. You don't
36/// need to directly interface with the different file types that might get
37/// returned: you should instead use the `EmbedableFile`  trait which is
38/// implemented for both.
39pub trait RustEmbed {
40    type File: EmbedableFile;
41
42    /// Get a file out of the folder.
43    fn get(file_path: &str) -> Option<Self::File>;
44}