Risk-sharing rules and their properties, with applications to peer-to-peer insurance