Theres a repl for rust that can be used in a Jupyter notebook. I am also curious about how it works under the hood but here it is for anyone to check out: https://github.com/google/evcxr
The way I did it for Go was by having a API start up on the local machine that executes the code and returns the result to VS Code, going to do the same for Rust.