The starting point for this body of law is the basic obligation to return a lost object: the Tur (Choshen Mishpat 259) rules that one who sees a lost object is obligated to occupy himself with it and return it to its owner, derived from the pasuk "hashev teshivem," but only when several conditions are met — the object shows clear signs of being lost, has a siman, is worth a perutah, and belongs to someone whose lost objects one is obligated to return.
The Gemara itself works out which objects qualify as "lost" in the first place: the Gemara (Bava Metzia 31a) teaches that a cloak or ax leaning against a fence, or a cow grazing among vineyards, is not considered lost property, whereas a cow running along a main thoroughfare is, and any object seen abandoned for three consecutive days crosses into the category of a lost object.
the Mishnah (Bava Metzia 2:1) draws a further line between found objects one may keep outright — such as scattered produce, scattered coins, and baker's loaves — and those requiring a public announcement, with Rabbi Meir permitting the former and Rabbi Yehuda requiring an announcement for anything bearing a distinguishing feature.
Once an object is in the finder's possession pending return, the Gemara (Bava Metzia 30a) specifies how it must be preserved: wooden vessels may be used lightly so they do not rot, copper vessels with cold or warm water but not directly on fire, silver vessels with cold water only, while gold and glass vessels may not be touched at all until Eliyahu comes — and the same standard that applies to a found object applies equally to a deposit.
Finally, when competing obligations arise, the Gemara (Bava Metzia 33a) establishes a hierarchy: one's own lost object takes precedence over his father's or teacher's, and between father and teacher the teacher's lost object comes first because, as the passage states, his father brought him into this world while his teacher brings him to life in the World-to-Come — a principle derived, as Rav Yehuda citing Rav notes, from the pasuk "there shall be no needy among you," understood to mean that your own needs precede those of any other person.