  We present the theory of rank-metric codes with respect to the 3-tensors that
generate them. We define the generator tensor and the parity check tensor of a
matrix code, and describe the properties of a code through these objects. We
define the tensor rank of a code to be the tensor rank of its generating
tensors, and propose that this quantity is a significant coding theoretic
parameter. By a result on the tensor rank of Kruskal from the 1970s, the tensor
rank of a rank-metric code of dimension $k$ and minimum rank distance $d$ is at
least $k+d-1$. We call codes that meet this bound minimal tensor rank (MTR)
codes. It is known from results in algebraic complexity theory that an MTR code
implies the existence of an MDS code. In this paper, we also address the
converse problem, that of the existence of an MTR code, given an MDS code. We
identify several parameters for which the converse holds and give explicit
constructions of MTR codes using MDS codes. We furthermore define generalized
tensor ranks, which give a refinement of the tensor rank as a code invariant.
Moreover, we use these to distinguish inequivalent rank-metric codes.
