| 77 | const ID: ProducerId = ProducerId::User; |
| 78 | |
| 79 | fn generate(&mut self, context: ProduceContext) -> Result<UserCreation, Self::Error> { |
| 80 | let local_id = self.local_id.take_and_advance(); |
| 81 | |
| 82 | let id_gid = context.global_id(local_id, Scope::Id, SubScope::Unknown); |
| 83 | let user_id = UserId::new(id_gid.encode()); |
| 84 | let shortname = format!("user-{:X}-{:X}", id_gid.shard_id, id_gid.local_id); |
| 85 | |
| 86 | let registration_gid = context.global_id(local_id, Scope::Registration, SubScope::Unknown); |
| 87 | let registration_complete = self |
| 88 | .registration_complete |
| 89 | .sample(&mut registration_gid.rng()); |
| 90 | |
| 91 | Ok(UserCreation { |
| 92 | id: user_id, |
| 93 | shortname, |
| 94 | registration_complete, |
| 95 | }) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | #[cfg(test)] |