China has laid out new rules that will legalize ride-hailing apps in a move welcomed by Didi Chuxing and Uber.