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<Generator> for Generator
impl PartialEq<Generator> 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§
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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.