pub struct KvpPrefixSampler { /* private fields */ }Expand description
Samples key-value “meta” prefixes with optional dropout.
Implementations§
Source§impl KvpPrefixSampler
impl KvpPrefixSampler
Sourcepub fn new(dropout: f32) -> Self
pub fn new(dropout: f32) -> Self
Create a new sampler that emits prefixes with the provided probability.
Sourcepub fn add_variant<K, V, I>(&mut self, fields: I)
pub fn add_variant<K, V, I>(&mut self, fields: I)
Register another variant using simple key-value pairs (single rendering per key).
Sourcepub fn add_variant_fields<I>(&mut self, fields: I)where
I: IntoIterator<Item = KvpField>,
pub fn add_variant_fields<I>(&mut self, fields: I)where
I: IntoIterator<Item = KvpField>,
Register another variant that may contain multi-valued fields.
Sourcepub fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Option<String>
pub fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Option<String>
Sample a formatted prefix using the configured dropout rate and variants.
Sourcepub fn all_metadata(&self) -> HashMap<String, Vec<String>>
pub fn all_metadata(&self) -> HashMap<String, Vec<String>>
Returns all metadata keys and all their possible values across every variant.
This method does not involve any RNG, presence rolls, or dropout — it simply
collects every key and every value defined on the sampler. Use the result to
populate RecordChunk::kvp_meta for downstream inspection/debugging.
Trait Implementations§
Source§impl Clone for KvpPrefixSampler
impl Clone for KvpPrefixSampler
Source§fn clone(&self) -> KvpPrefixSampler
fn clone(&self) -> KvpPrefixSampler
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KvpPrefixSampler
impl Debug for KvpPrefixSampler
Source§impl<'de> Deserialize<'de> for KvpPrefixSampler
impl<'de> Deserialize<'de> for KvpPrefixSampler
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for KvpPrefixSampler
impl RefUnwindSafe for KvpPrefixSampler
impl Send for KvpPrefixSampler
impl Sync for KvpPrefixSampler
impl Unpin for KvpPrefixSampler
impl UnsafeUnpin for KvpPrefixSampler
impl UnwindSafe for KvpPrefixSampler
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more