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§
source§impl 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§
source§impl GenerateValue<String> for Generator
impl GenerateValue<String> for Generator
source§impl GenerateValue<Value> for Generator
impl GenerateValue<Value> for Generator
source§impl GenerateValue<u16> for Generator
impl GenerateValue<u16> for Generator
source§impl PartialEq for Generator
impl PartialEq for Generator
impl Eq for Generator
Auto Trait Implementations§
impl Freeze for Generator
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
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
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.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>
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>
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