Immunity is your body's ability to destroy pathogens that it has previously encountered before the pathogens are able to cause disease.
This definition encompasses both the adaptive immune response, which specifically targets previously encountered pathogens, and the memory aspect that allows for a more rapid and effective response upon subsequent exposures.