If just considering the basic functionality of a switch, can I say that 2 devices connected (via ethernet cable) to a switch, is functionally equivalent to having those 2 devices directly connected to each other via ethernet cable?
It's a layer-2 connection though, so it depends on what exactly you're asking about. Some frames don't cross switched connections (depending on the switch) like BPDUs and LLDP frames.
Technically, the layer-1 link ends on the switch and the 2nd device is connected by another L1 link. The switch in between may or may not alter or filter the frames running through - add or remove 802.1Q tags, filter multicast traffic, filter according to its ACLs, apply 802.1X port security, ...
When a switch receives an ethernet frame, it looks at its mac address table to figure out out of which interface it need to send it to its destination. If two devices are connected directly then no such operations are involved.
Also your switch may be connected to a router and your devices maybe using that router as their default gateway. If you connect two devices directly then you wont have a gateway to reach the rest of the world.