pub struct Sequence { /* private fields */ }Expand description
The uniqueness source: a process-unique, time-derived base plus an atomic counter. Generated factory modules hold one per model:
ⓘ
static SEQ: Sequence = Sequence::new();
// …
id: self.id.resolve(f, |_| Set::Value(SEQ.next_i64())),Two promises, in order of strength:
- In-process, values never repeat — the counter is atomic, so
create_many(&db, 100)(and every factory call across every test in the binary) draws distinct values. - Across processes, collision is improbable — the base is taken from
the clock at first use (the same shape the Layer 2 spec’s
key()pinned), so runs against a shared persistent server land in different ranges. Improbable, not impossible: this is test-data machinery, not a coordination service.
Values are positive and fit i32, so the one sequence serves integer
(PostgreSQL/MySQL) and INTEGER (SQLite) primary keys alike.
Deliberately outside the Faker seed: sequences exist
for uniqueness, and a reproducible primary key against a shared server
would reproduce a collision (crate docs, “the determinism switch”).
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Sequence
impl RefUnwindSafe for Sequence
impl Send for Sequence
impl Sync for Sequence
impl Unpin for Sequence
impl UnsafeUnpin for Sequence
impl UnwindSafe for Sequence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more