include_bytes_from_url

Macro include_bytes_from_url 

Source
include_bytes_from_url!() { /* proc-macro */ }
Expand description

Includes a file from an URI as a reference to a byte array.

This macro will yield an expression of type &'static [u8; N] which is the contents of the file.

§Examples

Assume there is a remote files reachable via URI http://www.example.com/spanish.in, and it’s contents are:

adiós

File ‘main.rs’:

fn main() {
    let bytes = include_url::include_bytes_from_url!("http://www.example.com/spanish.in");
    assert_eq!(bytes, b"adi\xc3\xb3s\n");
    print!("{}", String::from_utf8_lossy(bytes));
}

Compiling ‘main.rs’ and running the resulting binary will print “adiós”.