General rigidity principles for stable and minimal elastic curves