You set a custom command (`Edit->Format->Send Selection To->Set Custom Commands`) and then when you activate it, it takes the selection and then sends it to the standard input of the command (in this case `rustfmt`) which does its thing (in this case formats Rust code) and then sends the result out of its standard output, which Geany then replaces the current selection with.
For example if you set `rustfmt` as the first custom command, the key sequence <kbd>Ctrl</kbd>+<kbd>a</kbd> <kbd>Ctrl</kbd>+<kbd>1</kbd> would format the entire current document.