A general theory of magnetically insulated electron flow