Static file timestamp

I have a Rocket application which can be built to serve its static content (javascript, svg's, css, etc) built into the binary using include_bytes. It occurred to me that this happens to make ETag support rather trivial, so I added that to the responder.

RFC2616, section 13.3.4, states that when using ETag one should also use Last-Modified "if it is feasible to send one". One could argue that since I'm inlining the files' contents in the binary, it's not really feasible to include the last modified timestamp (since there is no file metadata) .. however, let's say I would be in the mood to make my own life more difficult: I'm wondering if there's a solution to this where I would be able to, at build time, fetch the last-modification timestamp of the files and store them statically in the binary (sort-of like include_bytes does to the files' contents).

This feels waaaay too niche to actually exist, but I have thought so in the past and been pleasantly surprised, so I'm asking anyway.

I know I could pass the timestamps using environment variables, but I want something that's isolated to the module, because adding new static content is already sufficient fiddly.

While writing this it occurred to me that I should be able to do this with a build script. Posting anyway in case anyone has any other ideas.

I don't think it exists, but you can define your own procedural macro to do it.

That ... seems scary. :slight_smile:

I supposed I should dive into writing one of my own sooner or later, and perhaps this is a good first project for proc macros.

It certainly seems like it would be an interesting project!