You regain all of your hits after you finish resting. You must already be resting or begin resting immediately afterward to receive the effect, and it ends if your rest is interrupted.