Skip to main content

CTConfig

Struct CTConfig 

Source
pub struct CTConfig<T = u8, const REQUIRE_COMMA: bool = true, const TRAILING_COMMA: bool = false, const PRE_VALIDATE_UTF8: bool = true, const COMMENTS: bool = false> { /* private fields */ }
Expand description

Compile-time configuration for JSON parsing behavior.

Implementations§

Source§

impl<T, const A: bool, const B: bool, const C: bool> CTConfig<T, true, A, B, C>

Source

pub fn optional_comma(self) -> CTConfig<T, false, true, B, C>

Makes commas optional. As a side effect trailing commas are allowed automatically.

Source§

impl<T, const A: bool, const B: bool, const C: bool> CTConfig<T, A, false, B, C>

Source

pub fn allow_trailing_comma(self) -> CTConfig<T, A, true, B, C>

Allows trailing commas when parsing.

Source§

impl<T, const A: bool, const B: bool, const C: bool> CTConfig<T, A, B, true, C>

Source

pub fn disable_utf8_pre_validation(self) -> CTConfig<T, A, B, false, C>

Disables UTF-8 pre-validation, which would otherwise be performed eagerly when possible.

Performing a single UTF-8 validation over the whole source is usually faster than doing it for each JSON string that is parsed. However, it can be considered overhead when the JSON has little to no strings.

Without this, the default behavior is to pre-validate the entire source for UTF-8 when the source is non-volatile and not guaranteed to be valid UTF-8 already.

Source§

impl<T, const A: bool, const B: bool, const C: bool, const D: bool> CTConfig<T, A, B, C, D>

Source

pub fn depth_limit<U>(self, v: U) -> CTConfig<U, A, B, C, D>

Sets depth limit for the input JSON.

Source§

impl CTConfig

Source

pub fn new() -> Self

Creates a compile-time configuration with default settings.

By default, commas are required and both trailing commas and comments are not allowed.

Source§

impl<T, const A: bool, const B: bool, const C: bool> CTConfig<T, A, B, C>

Source

pub fn allow_comments(self) -> CTConfig<T, A, B, C, true>

Available on crate feature comment only.

Allows comments when parsing.

Trait Implementations§

Source§

impl<T: Clone, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> Clone for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>

Source§

fn clone( &self, ) -> CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>

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<T: Depth, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> Config for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>

Source§

impl<T: Copy, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> Copy for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>

Auto Trait Implementations§

§

impl<T, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> Freeze for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>
where T: Freeze,

§

impl<T, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> RefUnwindSafe for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>
where T: RefUnwindSafe,

§

impl<T, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> Send for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>
where T: Send,

§

impl<T, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> Sync for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>
where T: Sync,

§

impl<T, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> Unpin for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>
where T: Unpin,

§

impl<T, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> UnsafeUnpin for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>
where T: UnsafeUnpin,

§

impl<T, const REQUIRE_COMMA: bool, const TRAILING_COMMA: bool, const PRE_VALIDATE_UTF8: bool, const COMMENTS: bool> UnwindSafe for CTConfig<T, REQUIRE_COMMA, TRAILING_COMMA, PRE_VALIDATE_UTF8, COMMENTS>
where T: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.