First, a small bit of terminology fixing, you can’t usefully store any reference &... inside a file, because a reference must contain the memory address of its target. That changes between program executions, and so when you load the file again the old memory address could be anything.
What you’re talking about is treating a portion of the memory mapped file as a slice [u8] and taking a reference to it. This is certainly possible, but will depend on the details of the API that you’re using to memory map the file. Assuming it gives you a raw pointer *mut u8, you can convert that into a mutable slice reference &mut [u8] via slice::from_raw_parts_mut. All you need to tell it is a pointer to the first element and the number of elements in the slice.
To generate a shared reference &[u8], there’s a corresponding function from_raw_parts.
Thanks, you're absolutely right, my terminology above was inaccurate.
Inside of the memory mapped file, I want to store an contiguous block of u8's. Then, I want to be able to treat this block of u8's as a &[u8], without making a copy of it, which your recommendation of slice::from_raw_parts solves. Thanks!
One slight warning here: if the OS updates your mapping while you hold a reference (vs. a raw pointer), you’ve entered UB-land, and there’s no way to reason about whether the new or old value is used in any given calculation, among other things. It may be safer to do the copy, which will likely just update entries in the process’s virtual memory table and not actually copy any bytes in main memory.