Skip to main content

assign_peer_colors

Function assign_peer_colors 

pub fn assign_peer_colors(
    ids: &[&str],
    reserved: &[(u8, u8, u8)],
) -> HashMap<String, (u8, u8, u8)>
Expand description

Give everyone in a room a colour nobody else in it is wearing.

user_color alone can’t promise this — it’s a hash, so carol lands on alice’s pink. Whoever collides steps to the next free ring entry, walking ids in sorted order so every host agrees despite seeing a different membership (everyone but itself). reserved colours are already spoken for by an explicit roster choice.