This might be a stupid question but I genuinely don’t know.

How does charging something using just the wire of a USB C charger work? For instance I can charge my headphones with the wire plugged into my iPhone or an iPad does it work by using the battery of the iPhone to be able to charge the headphones?