FieldBuilder

Struct FieldBuilder 

Source
pub struct FieldBuilder<Parent, Value, List> { /* private fields */ }
Expand description

A builder to record parsing results for a field of the input.

Implementations§

Source§

impl<Parent, Value, List> FieldBuilder<Parent, Value, List>
where Parent: ErrorBuilderParent<Value>,

Source

pub fn value<T, E>( self, result: Result<T, E>, ) -> FieldBuilder<Parent, Value, List::Output>
where List: Append<T>, E: Error + Send + Sync + 'static,

Record a parsing result for the field.

Source

pub fn value_ok<T>(self, value: T) -> FieldBuilder<Parent, Value, List::Output>
where List: Append<T>,

Record a value for the field.

This is infallible so it’s easy to insert values that do not need parsing in the ErrorAccumulator’s system.

Source

pub fn with_previous<Valid, T, E>( self, validator: Valid, ) -> FieldBuilder<Parent, Value, List::Output>
where Valid: ListValidator<List, T, E>, List: AsRefTuple + Append<T>, E: Error + Send + Sync + 'static,

Run another validation step on the previously recorded Ok values if there were no errors yet.

In case an error was already recorded the validator is not executed.

For an example, see the docs of StructBuilder::with_previous().

Source

pub fn on_ok<C>(self, constructor: C) -> BuilderFinisher<Parent, Value, List, C>
where List: ToTuple, C: Constructor<List::List, Value>,

Provide a Constructor to convert the recorded Ok values into the target type.

Source§

impl<Parent, Value> FieldBuilder<Parent, Value, Cons<Value, Nil>>
where Parent: ErrorBuilderParent<Value>,

Source

pub fn finish(self) -> Parent::AfterRecord

Finish the builder and pass the builder’s final result to the parent builder.

Trait Implementations§

Source§

impl<Parent: Debug, Value: Debug, List: Debug> Debug for FieldBuilder<Parent, Value, List>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Parent, Value, List> Freeze for FieldBuilder<Parent, Value, List>
where Parent: Freeze, List: Freeze,

§

impl<Parent, Value, List> !RefUnwindSafe for FieldBuilder<Parent, Value, List>

§

impl<Parent, Value, List> Send for FieldBuilder<Parent, Value, List>
where Parent: Send, List: Send, Value: Send,

§

impl<Parent, Value, List> Sync for FieldBuilder<Parent, Value, List>
where Parent: Sync, List: Sync, Value: Sync,

§

impl<Parent, Value, List> Unpin for FieldBuilder<Parent, Value, List>
where Parent: Unpin, List: Unpin, Value: Unpin,

§

impl<Parent, Value, List> !UnwindSafe for FieldBuilder<Parent, Value, List>

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