  We introduce a new technique to construct rank-metric codes using the
arithmetic theory of Drinfeld modules over global fields, and Dirichlet Theorem
on polynomial arithmetic progressions. Using our methods, we obtain a new
infinite family of optimal rank-metric codes with rank-locality, i.e. every
code in our family achieves the information theoretical bound for rank-metric
codes with rank-locality.
