Baptism can be received by either a formal Baptism (the ceremony with water and words) or by a non-formal Baptism (i.e. of desire).
A Baptism of desire can be either explicit or implicit. An explicit Baptism of desire occurs when a person desires to be baptized, but is unable to obtain baptism. Often the situation is that the person dies before obtaining Baptism.
An implicit Baptism of desire occurs when an unbaptized person knowingly chooses an act of true selfless spiritual love in full cooperation with grace.
Pope Pius XII: “Above all, the state of grace is absolutely necessary at the moment of death without it salvation and supernatural happiness – the beatific vision of God – are impossible. An act of love is sufficient for the adult to obtain sanctifying grace and to supply the lack of baptism….”
Pope Pius XII, Address to Midwives, 29 October 1951.
See also my article, Treatise on Mystical Baptism.
catholicplanet.com/RCC/mystical-baptism.htm