[−][src]Enum mockery::datatypes::RandomData
An Enum that represents all of the possible random data generation types. Where the type is a struct it should be written in a specification as a nested map type, where the outer map contains a single property correlating to the struct variant with value should be a map containing the struct values.
Examples
Basic Model (JSON)
To model a company identification card that contains basic employee information using simple types:
{
"information_card": {
"name": "FullName",
"contact_email": "Email",
"contact_number": "PhoneNumber",
"address": "FullAddress"
}
}
Model With Struct Types (JSON)
To use complex data types that take arguments, you need to write the property values as
nested map types. This example models an Under-25 Travelcard for a train company, where
the age of the person needs to be between 18 and 25. The NumberBetween
type takes two
arguments:
{
"travelcard": {
"name": "FullName",
"address": "FullAddress",
"age": {
"NumberBetween": {
"min": 18,
"max": 25
}
}
}
}
Variants
Generates a latin first name
Generates a latin surname
Generates a combination of a FirstName
and LastName
, combined with a space between them
Generates a safe email address
Generates an integer with the given number of digits.
Examples
Number: { "digits": 3 }
will generate a number between 100 and 999, inclusive
Fields of Number
digits: usize
The number of digits the generated number should have, to get a number with an appropriate order of magnitude
Generate a random number between the minimum and maximum boundaries
Examples
NumberBetween: { "min": 23, "max": 50 }
will generate a number between 23 and 49, inclusive
Fields of NumberBetween
Generate a number of paragraphs containing raw lorem ipsum text (No formatting)
Generate a single paragraph of lorem ipsum text. This is a convenience for specifying
Paragraphs
as a simple type without options
Generate a number of sentences containing raw lorem ipsum text (No formatting)
Generate a single sentence of lorem ipsum text. This is a convenience for specifying
Sentences
as a simple type without options
Generates the name of a local company - usually an amalgamation of name-parts
Generates the name of a city
Generates a sensible street address (including house number and street name components)
Generates a valid latitude component
Generates a valid longitude component
Generates a coordinate pair, formatted as a JSON array of (Latitude, Longitude)
Generates a coordinate pair, formatted as a JSON array of (Longitude, Latitude)
Generates a GeoJson point object using the WKT formatting for postgis recognition and insertion
Generates a valid postcode
Generates an address with StreetAddress
, City
and PostCode
components, separated by commas
Generates a valid V4 UUID, generally useful for object IDs
Generates a valid phone number
Generates a URL to a random picture with the given dimensions and optional greyscale mode. Where one of the size values is absent, the image will be a square as dictated by the other value that is present. Where both are absent, the image will be a 200x200 pixel square.
Fields of String
content: String
Methods
impl RandomData
[src]
pub fn into_data(self) -> String
[src]
Consumes the RandomData
instance and turns it into a random piece of data, corresponding to
its type
Trait Implementations
impl Clone for RandomData
[src]
fn clone(&self) -> RandomData
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ToString for RandomData
[src]
impl Debug for RandomData
[src]
impl Serialize for RandomData
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for RandomData
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Send for RandomData
impl Sync for RandomData
impl Unpin for RandomData
impl UnwindSafe for RandomData
impl RefUnwindSafe for RandomData
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Fake for T
[src]
fn fake<U>(&self) -> U where
Self: FakeBase<U>,
[src]
Self: FakeBase<U>,
fn fake_with_rng<U, R>(&self, rng: &mut R) -> U where
R: Rng + ?Sized,
Self: FakeBase<U>,
[src]
R: Rng + ?Sized,
Self: FakeBase<U>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,