All-optical ultrafast spin rotation for relativistic charged particle beams