0

I want to embed an image file in my project. To be more precise, I would like to embed the loaded Rust object containing the image, in my case a usvg::Tree, or even more advanced, a cairo::ImageSurface. Would that be possible? I only find examples for Strings.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Natjo
  • 2,005
  • 29
  • 75
  • 3
    include byte can include any byte so... anything, as your lib seem to have a `from_raw` function just use it. – Stargateur Nov 18 '19 at 19:37

1 Answers1

1

Yes.

From the documentation:

Includes a file as a reference to a byte array.

The file is located relative to the current file. (similarly to how modules are found)

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

There is no restriction on the type of data. The literal bytes are included. It's worth recognizing that it's up to you to ensure that the bytes make sense for the platform that the code runs on and that you have some way of parsing the bytes.

See also:

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366