Bleg on temporary of seizures firearms

I would be grateful if commenters could point to cases, statutes, or secondary materials which address these questions: In Terry stops, traffic stops, and other police encounters with individuals which do not involve an arrest, under what circumstances can a law enforcement officer temporarily detain a person’s firearm? For example, for officer safety during a traffic stop? To call a central database and see if the gun’s serial number is on a list of stolen guns?