When talking about the rest energy of a composite particle such as a proton, part of the rest energy is accounted for by the internal kinetic energy of its constituent quarks. But what is physically meant by the rest energy of non-composite particles such as quarks?
One has to be familiar with four vectors. In the same way as for three vectors the length is an invariant of the vector and is obtained by the dot product of the vector with itself, the "length" of the relativistic four vector is the rest mass, by definition;
the mass $m$ entering the relativistic equation where $p$ is the momentum and $E$ the total energy,
$E^2 - p^2c^2 = m^2c^4$
when $p=0$ is the rest energy.
In a composite particle the invariant mass even when it is at rest is the invariant mass of the four vector composed by adding the four vectors of all the constituent particles . A composite particle displays an effective rest mass.
For a non composite particle, as the electron, the energy when at rest, $p=0$, is its mass.