valico::json_schema::builder

Struct Builder

Source
pub struct Builder { /* private fields */ }
Expand description

Builder provides simple DSL to build Schema. It allows you not to use strings and raw JSON manipulation. It also prevent some kinds of spelling and type errors.

Implementations§

Source§

impl Builder

Source

pub fn new() -> Builder

Source

pub fn id(&mut self, url: &str)

Source

pub fn ref_(&mut self, url: &str)

Source

pub fn schema(&mut self, url: &str)

Source

pub fn desc(&mut self, text: &str)

Source

pub fn title(&mut self, text: &str)

Source

pub fn default<T>(&mut self, default: T)
where T: Serialize,

Source

pub fn multiple_of(&mut self, number: f64)

Source

pub fn maximum(&mut self, number: f64, exclusive: bool)

Source

pub fn minimum(&mut self, number: f64, exclusive: bool)

Source

pub fn max_length(&mut self, number: u64)

Source

pub fn min_length(&mut self, number: u64)

Source

pub fn pattern(&mut self, pattern: &str)

Source

pub fn format(&mut self, format: &str)

Source

pub fn items_schema<F>(&mut self, build: F)
where F: FnOnce(&mut Builder),

Source

pub fn items_array<F>(&mut self, build: F)
where F: FnOnce(&mut SchemaArray),

Source

pub fn additional_items(&mut self, allow: bool)

Source

pub fn additional_items_schema<F>(&mut self, build: F)
where F: FnOnce(&mut Builder),

Source

pub fn max_items(&mut self, number: u64)

Source

pub fn min_items(&mut self, number: u64)

Source

pub fn unique_items(&mut self, unique: bool)

Source

pub fn max_properties(&mut self, number: u64)

Source

pub fn min_properties(&mut self, number: u64)

Source

pub fn required(&mut self, items: Vec<String>)

Source

pub fn properties<F>(&mut self, build: F)
where F: FnOnce(&mut SchemaHash),

Source

pub fn pattern_properties<F>(&mut self, build: F)
where F: FnOnce(&mut SchemaHash),

Source

pub fn additional_properties(&mut self, allow: bool)

Source

pub fn additional_properties_schema<F>(&mut self, build: F)
where F: FnOnce(&mut Builder),

Source

pub fn dependencies<F>(&mut self, build: F)
where F: FnOnce(&mut Dependencies),

Source

pub fn enum_<F>(&mut self, build: F)
where F: FnOnce(&mut ArrayBuilder),

Source

pub fn array(&mut self)

Source

pub fn boolean(&mut self)

Source

pub fn integer(&mut self)

Source

pub fn number(&mut self)

Source

pub fn null(&mut self)

Source

pub fn object(&mut self)

Source

pub fn string(&mut self)

Source

pub fn type_(&mut self, type_: PrimitiveType)

Source

pub fn types(&mut self, types: &[PrimitiveType])

Source

pub fn all_of<F>(&mut self, build: F)
where F: FnOnce(&mut SchemaArray),

Source

pub fn any_of<F>(&mut self, build: F)
where F: FnOnce(&mut SchemaArray),

Source

pub fn one_of<F>(&mut self, build: F)
where F: FnOnce(&mut SchemaArray),

Source

pub fn not<F>(&mut self, build: F)
where F: FnOnce(&mut Builder),

Source

pub fn build<F>(build: F) -> Builder
where F: FnOnce(&mut Builder),

Source

pub fn into_json(self) -> Value

Trait Implementations§

Source§

impl Serialize for Builder

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetTypeId for T
where T: Any,

Source§

fn typeid(&self) -> TypeId

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.