error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
8 | Box::new(*bytes)
| ^^^^^^^^ doesn't have a size known at compile-time
= help: the trait `Sized` is not implemented for `[u8]`
= note: all function arguments must have a statically known size
& is borrowing in Rust. It sort-of means "I temporarily let you see the data in have, but it will go away". In your case the data is in a variable, and variables get destroyed at the end of their scope (nearest }), so you can't let anyone outside of a function have a peek at content of a variable inside the function — the data will be gone before you return the view into it.
You have to use a type that isn't borrowing the variable, like Box<[u8]> or Vec<u8>. In Rust the ownership difference between &[u8] and Box<[u8]> is very important. In GC languages it doesn't matter whether something is in a variable or not. In Rust it is a semantically meaningful difference.
It's important to note that a type like Box<&[u8]> behaves pretty much exactly like &[u8]. That the outer smart-pointer is owned doesn't change the fact that you have a borrowed type inside it. You just have ownership of a borrow.