During a flight, what kinds of emergencies or failures should I report to ATC immediately? For what kind of emergencies or failures am I not required to report them?
What is the general rule? Could I have some examples?
You don't specify a country, so I'll answer for the US and hope that other countries are similar.
14 CFR 91.183(c) is the closest I can find to a "requirement" to report an emergency. It only directly applies to IFR flights, but I can see no reason why VFR flights shouldn't do the same.
My rule of thumb is that if I wouldn't have taken off had I known about the problem then, it needs to be reported now. Common examples might be low fuel, rough engine, weather approaching VFR limits or required instrument failure.
Note that while the FAA earned a bad rap for excessive enforcement actions in the 1980s, in the 1990s they adopted the stance that declaring an emergency is a sign of good decision making and risk management, and the stats since then show virtually no enforcement actions after emergencies, so when in doubt, I'd err on the side of declaring. At worst, there may be a "counseling session" if they later decide that the situation didn't warrant it.
In an emergency, ATC have two main roles:
1) To ensure you don't hit anything (be it a mountain or another aircraft); 2) To ensure that you will be met with appropriate resources on the ground.
So if you're going to need either of those things, or in any other way can't abide by normal procedures, ATC needs to know.
So ATC need to know if you're conducting a flapless landing because you need greater separation due to your higher approach speed. They don't need to know that you're turning back because of an inoperative fuel pump below MLW - but they will likely ask you of the nature of the problem to make sure they can't do anything.