pub struct SchemaBuilder { /* private fields */ }
Expand description

Builds schemas up from Validators.

A schema can be directly made from any document, but it’s generally much easier to construct them from Validator structs and turn the result into a Document.

Implementations§

source§

impl SchemaBuilder

source

pub fn new(doc: Validator) -> Self

Start building a new schema. Requires the validator to use for any documents adhering to this schema.

source

pub fn description(self, description: &str) -> Self

Set the schema description. This is only used for documentation purposes.

source

pub fn doc_compress(self, doc_compress: Compress) -> Self

Set the default compression to use for documents adhering to this schema.

source

pub fn entry_add( self, entry: &str, validator: Validator, compress: Option<Compress> ) -> Self

Add a new entry type to the schema, where entry is the key for the entry, validator will be used to validate each entry, and compress optionally overrides the default compression with a specific compression setting.

source

pub fn name(self, name: &str) -> Self

Set the schema name. This is only used for documentation purposes.

source

pub fn type_add(self, type_ref: &str, validator: Validator) -> Self

Add a new stored type to the schema.

source

pub fn type_get(&self, type_ref: &str) -> Option<&Validator>

Look up a type that has already been stored.

source

pub fn version<T: Into<Integer>>(self, version: T) -> Self

Set the schema version. This is only used for documentation purposes.

source

pub fn regexes(self, max_regex: u8) -> Self

Set the maximum number of regexes allowed in a query.

source

pub fn build(self) -> Result<Document>

Build the Schema, compiling the result into a Document

Trait Implementations§

source§

impl Clone for SchemaBuilder

source§

fn clone(&self) -> SchemaBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SchemaBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.