Multilayer ReS2 lateral p–n homojunction for photoemission and photodetection