How does protocol dispatch work?

For example, how does Kernel‘s to_string “know” that it belongs to String.Chars?

If I do a defimpl String.Chars, for: MyMod – how does to_string know
to call my implemented function?

Just curious.