Enum pact_models::generators::Generator
source · [−]pub enum Generator {
Show 13 variants
RandomInt(i32, i32),
Uuid(Option<UuidFormat>),
RandomDecimal(u16),
RandomHexadecimal(u16),
RandomString(u16),
Regex(String),
Date(Option<String>, Option<String>),
Time(Option<String>, Option<String>),
DateTime(Option<String>, Option<String>),
RandomBoolean,
ProviderStateGenerator(String, Option<DataType>),
MockServerURL(String, String),
ArrayContains(Vec<(usize, MatchingRuleCategory, HashMap<DocPath, Generator>)>),
}
Expand description
Trait to represent a generator
Variants
RandomInt(i32, i32)
Generates a random integer between the min and max values
Uuid(Option<UuidFormat>)
Generates a random UUID value
RandomDecimal(u16)
Generates a random sequence of digits
RandomHexadecimal(u16)
Generates a random sequence of hexadecimal digits
RandomString(u16)
Generates a random string of the provided size
Regex(String)
Generates a random string that matches the provided regex
Date(Option<String>, Option<String>)
Generates a random date that matches either the provided format or the ISO format
Time(Option<String>, Option<String>)
Generates a random time that matches either the provided format or the ISO format
DateTime(Option<String>, Option<String>)
Generates a random timestamp that matches either the provided format or the ISO format
RandomBoolean
Generates a random boolean value
ProviderStateGenerator(String, Option<DataType>)
Generates a value that is looked up from the provider state context
MockServerURL(String, String)
Generates a URL with the mock server as the base URL
ArrayContains(Vec<(usize, MatchingRuleCategory, HashMap<DocPath, Generator>)>)
List of variants which can have embedded generators
Implementations
sourceimpl Generator
impl Generator
sourcepub fn from_map(gen_type: &str, map: &Map<String, Value>) -> Option<Generator>
pub fn from_map(gen_type: &str, map: &Map<String, Value>) -> Option<Generator>
Converts a JSON map into a Generator
struct, returning None
if it can not be converted.
sourcepub fn corresponds_to_mode(&self, mode: &GeneratorTestMode) -> bool
pub fn corresponds_to_mode(&self, mode: &GeneratorTestMode) -> bool
If this generator is compatible with the given generator mode
Trait Implementations
sourceimpl GenerateValue<String> for Generator
impl GenerateValue<String> for Generator
sourceimpl GenerateValue<Value> for Generator
impl GenerateValue<Value> for Generator
sourceimpl GenerateValue<u16> for Generator
impl GenerateValue<u16> for Generator
impl Eq for Generator
impl StructuralEq for Generator
Auto Trait Implementations
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more