In the United States, at least, diplomatic immunity can be used as essentially a complete defense against any crime, no matter how serious. As the link below says,
If diplomatic immunity is used as a shield, the police cannot prosecute, no matter how serious the crime may be.
This is true of full fledged diplomatic agents and of their immediate families. This is why, for example, the son of a diplomat was allowed to leave the country in 1983 even though he was suspected of multiple rapes.
If the country that the diplomat is from agrees, however, the diplomat can actually be turned over to the US court system. In that sense, diplomatic immunity is not a complete defense, but the diplomat's country does have to agree.
In addition, diplomatic immunity extends to civil cases. A diplomat may not be sued in the United States.
It not only is a credible and complete legal defense, it also obviates the need for one at all. If you look at UN diplomats and some of their senior staff members, who live and work in New York and are all granted diplomatic immunity, law enforcement officials cannot detain them in any way once they realize they have diplomatic plates or credentials. They cannot pull them over, give them a DUI check, or even write them a speeding ticket.
So the fact that they have diplomatic immunity means they cannot be prosecuted at all, or charged, or even arrested. Someone either has diplomatic immunity, or they do not. There is no grey area. Ad if they have it, then no defense is even necessary.