pub struct ValueGenerator { /* private fields */ }Expand description
Namespace for schema-guided JSON value generation.
Call ValueGenerator::generate with a SchemaDocument, GenerationConfig,
and random number generator. The struct itself does not expose a public
constructor because generation state is an implementation detail.
Implementations§
Source§impl ValueGenerator
impl ValueGenerator
Sourcepub fn generate(
schema: &SchemaDocument,
config: GenerationConfig,
rng: &mut impl Rng,
) -> Result<Value, GenerateError>
pub fn generate( schema: &SchemaDocument, config: GenerationConfig, rng: &mut impl Rng, ) -> Result<Value, GenerateError>
Generate one JSON value accepted by the raw schema validator.
This method first builds candidates from the document’s resolved
canonical AST, then checks every candidate with
SchemaDocument::is_valid. If the resolved root is known to have no
valid instances, it returns GenerateError::Unsatisfiable without
spending the retry budget. If the schema may be satisfiable but the
heuristic candidate generator cannot find a raw-valid value in time, it
returns GenerateError::ExhaustedAttempts.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ValueGenerator
impl RefUnwindSafe for ValueGenerator
impl Send for ValueGenerator
impl Sync for ValueGenerator
impl Unpin for ValueGenerator
impl UnsafeUnpin for ValueGenerator
impl UnwindSafe for ValueGenerator
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> 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