You can not rest when enemies are nearby, or immediately after being in combat or casting a spell. In certain areas you can not rest at all, and in other areas enemies may interrupt you while resting. In the official campaign it takes 5 seconds to rest, and there are no other restrictions on how often you can do so. The rules of resting may be different in other modules.
Spell effects that are not permanent will end when resting. Mage armor, for example, will disappear when resting, but the effects of Bestow curse will not. Supernatural effects are not removed by resting, but Magical and Extraordinary effects are removed.
Hit points and spells are regained periodically while resting, so even if the rest is ended prematurely, some hit points and spells will still be regained. All buffs are removed immediately when the rest is initiated, though. Spells regained start with the lowest spell levels, progressing towards the higher spell levels. Therefore, cantrips are recharged first, and your highest level spells will require a complete rest to regain.
- Resting works the same way as it did in NWN.