Design 1:
A high thermal mass piece of porous material, which air flows in and out through the same holes. As air is exhaled, the material warms up. As air is inhaled, the material gives collected heat to the incoming air.
Design 2:
As above, but there are two sets of paths through the material. The paths are in a checkerboard pattern so there is good thermal conductivity between them. One set is for incoming fresh air and the other for used air. One way valves ensure air travels in the correct direction through each hole.
Design 1 is great for keeping both heat and moisture (air will be pre humidified on the way in). However, it has the downside that all of the air in the tubes will be re-inhaled in each breath. Effectively your lung capacity will be reduced by the volume of the mask.
Design 2 is more mechanically complex, gives you very dry air to breathe in, and will be prone to clogging with condensation, but has the advantage that you aren't rebreathing any CO2 laden air. And just 2% breathed back in causes "complaints of drowsiness and poor air"[1]
[1]: https://www.dhs.wisconsin.gov/chemical/carbondioxide.htm