The maintainer can write(/adopt) a CoC as a tool to make it easy for me to not be a dickhead. The effectiveness of that is gonna vary, communication is hard. Still better than nothing.
Publishing informal thoughts or a semi-formal moderation policy is effective communication. Publishing a pseudo-legal code sends the message that you will be making legalistic judgements and pronouncements.