It’s a small linear motor which [ligonapProduktion ... neodymium magnets inside the shaft. The set of four coils is driven by an ATtiny44. Just like a stepper motor, energizing the coils ...
If one-dimensional movement is enough for you, though, check out this linear stepper motor that works on a similar principle.