pub struct RandomDrawProjection { /* private fields */ }Expand description
The deterministic random() draw-ordinal projection for one run.
Bound to the run’s (WorkflowId, RunId), it reproduces — for any draw
ordinal — the exact value the production determinism NIF serves, by calling
the same deterministic_float / deterministic_i64 the NIF calls. Draw
ordinals start at 0 (the first workflow.random() call a run makes draws
ordinal 0), matching the handle’s pre-increment sequence counter.
This carries no draw count: the number of draws a run makes is workflow-code
dependent and unrecoverable from history alone (module docs). It answers
“what would random() return at ordinal n?”, never “how many draws did
step k make?”.
Implementations§
Source§impl RandomDrawProjection
impl RandomDrawProjection
Sourcepub fn random_at(&self, ordinal: u64) -> f64
pub fn random_at(&self, ordinal: u64) -> f64
The f64 in [0.0, 1.0) workflow.random() returns at draw ordinal.
This is byte-for-byte the value the production random() NIF serves at
that ordinal for this run — it calls the same deterministic_float.
Sourcepub fn random_int_at(
&self,
ordinal: u64,
min: i64,
max: i64,
) -> Result<i64, DurabilityError>
pub fn random_int_at( &self, ordinal: u64, min: i64, max: i64, ) -> Result<i64, DurabilityError>
The i64 in [min, max] workflow.random_int(min, max) returns at draw
ordinal.
This is the value the production random_int NIF serves at that ordinal
for this run — it calls the same deterministic_i64.
§Errors
Returns DurabilityError::HistoryShape when min > max, mirroring the
NIF’s loud rejection of an inverted range (no silent clamping).
Trait Implementations§
Source§impl Clone for RandomDrawProjection
impl Clone for RandomDrawProjection
Source§fn clone(&self) -> RandomDrawProjection
fn clone(&self) -> RandomDrawProjection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RandomDrawProjection
impl Debug for RandomDrawProjection
impl Eq for RandomDrawProjection
Source§impl PartialEq for RandomDrawProjection
impl PartialEq for RandomDrawProjection
impl StructuralPartialEq for RandomDrawProjection
Auto Trait Implementations§
impl Freeze for RandomDrawProjection
impl RefUnwindSafe for RandomDrawProjection
impl Send for RandomDrawProjection
impl Sync for RandomDrawProjection
impl Unpin for RandomDrawProjection
impl UnsafeUnpin for RandomDrawProjection
impl UnwindSafe for RandomDrawProjection
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.