2020, maybe 2021
You are partially correct about declared candidates being off limits from prosecution, depends on the crime.
But this entire process is going to be exceedingly slow in any case, and it is easy to imagine Trump needing to get re-election out of the way before anything dramatic happens, so that 2020 election is not tainted by "political prosecutions"