MCPcopy Create free account
hub / github.com/hashintel/hash / generate

Method generate

tests/graph/test-data/rust/src/seeding/producer/user.rs:79–96  ·  view source on GitHub ↗
(&mut self, context: ProduceContext)

Source from the content-addressed store, hash-verified

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)]

Callers 1

nextMethod · 0.45

Calls 6

OkInterface · 0.85
take_and_advanceMethod · 0.80
global_idMethod · 0.80
rngMethod · 0.80
encodeMethod · 0.45
sampleMethod · 0.45

Tested by

no test coverage detected