Skip to main content

Options

Struct Options 

Source
pub struct Options {
    pub date_to_date_time: Option<bool>,
    pub clone_schema: Option<bool>,
    pub support_pattern_properties: Option<bool>,
    pub keep_not_supported: Option<Vec<String>>,
    pub strict_mode: Option<bool>,
    pub remove_read_only: Option<bool>,
    pub remove_write_only: Option<bool>,
    pub pattern_properties_handler: Option<PatternPropertiesHandler>,
    pub definition_keywords: Option<Vec<String>>,
    pub before_transform: Option<BeforeTransform>,
    pub after_transform: Option<AfterTransform>,
}
Expand description

Caller-facing options. Every field is optional. Unset fields take the defaults described on ResolvedOptions.

Two ways to set options. Use struct-update syntax against Options::new:

let options = Options {
    support_pattern_properties: Some(true),
    ..Options::new()
};

Or chain the setters, which take plain values and wrap them for you:

let options = Options::new()
    .support_pattern_properties(true)
    .strict_mode(false);

Fields§

§date_to_date_time: Option<bool>

Rewrite format: "date" to format: "date-time". Default false.

§clone_schema: Option<bool>

Accepted for compatibility and ignored. Conversion takes the input by value and never mutates the caller’s data, so the output is the same whether this is set or unset. Default true.

§support_pattern_properties: Option<bool>

Move x-patternProperties to patternProperties and run the handler. Default false.

§keep_not_supported: Option<Vec<String>>

Keywords to keep that would otherwise be stripped. Each entry is removed from the strip list. Default empty.

§strict_mode: Option<bool>

Reject input type values outside the draft-04 type set. Default true.

§remove_read_only: Option<bool>

Drop object properties marked readOnly: true. Default false.

§remove_write_only: Option<bool>

Drop object properties marked writeOnly: true. Default false.

§pattern_properties_handler: Option<PatternPropertiesHandler>

Replacement for the default patternProperties handler.

§definition_keywords: Option<Vec<String>>

Dotted paths whose values hold named sub-schemas to convert, for example "definitions" or "schema.definitions". Default empty.

§before_transform: Option<BeforeTransform>

Hook run on each node before keyword processing.

§after_transform: Option<AfterTransform>

Hook run on each node after keyword processing.

Implementations§

Source§

impl Options

Source

pub fn new() -> Self

Construct empty options. Equivalent to Options::default.

Source

pub fn date_to_date_time(self, value: bool) -> Self

Set date_to_date_time. See the field for meaning.

Source

pub fn clone_schema(self, value: bool) -> Self

Set clone_schema. Accepted for compatibility and has no effect.

Source

pub fn support_pattern_properties(self, value: bool) -> Self

Set support_pattern_properties. See the field for meaning.

Source

pub fn keep_not_supported(self, value: Vec<String>) -> Self

Set keep_not_supported. See the field for meaning.

Source

pub fn strict_mode(self, value: bool) -> Self

Set strict_mode. See the field for meaning.

Source

pub fn remove_read_only(self, value: bool) -> Self

Set remove_read_only. See the field for meaning.

Source

pub fn remove_write_only(self, value: bool) -> Self

Set remove_write_only. See the field for meaning.

Source

pub fn definition_keywords(self, value: Vec<String>) -> Self

Set definition_keywords. See the field for meaning.

Source

pub fn pattern_properties_handler<F>(self, handler: F) -> Self
where F: Fn(Value) -> Value + Send + Sync + 'static,

Set the patternProperties handler from a plain closure. The closure is boxed for you, so callers do not write Arc::new.

Source

pub fn before_transform<F>(self, hook: F) -> Self
where F: Fn(Value, &ResolvedOptions) -> Value + Send + Sync + 'static,

Set the before-transform hook from a plain closure. The closure is boxed for you.

Source

pub fn after_transform<F>(self, hook: F) -> Self
where F: Fn(Value, &ResolvedOptions) -> Value + Send + Sync + 'static,

Set the after-transform hook from a plain closure. The closure is boxed for you.

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Options

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Options

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Options

Source§

fn default() -> Options

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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> ToOwned for T
where T: Clone,

Source§

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 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.