A study on the mechanism of formation of electrocodeposited Ni–diamond coatings