Skip to main content

ChildCursor

Struct ChildCursor 

Source
pub struct ChildCursor<N> { /* private fields */ }
Expand description

Single-pass field selection used only by generated migration code.

Implementations§

Source§

impl<N: ExternalCstNode> ChildCursor<N>

Source

pub fn new(parent: &N) -> Self

Collects the children of parent for single-pass field selection.

Source

pub fn required_field(&mut self, field: &'static str) -> Result<N, MigrateError>

Takes the child in required named field.

§Errors

Returns MigrateError::MissingField when no child occupies it.

Source

pub fn optional_field(&mut self, field: &'static str) -> Option<N>

Takes the child in optional named field.

Source

pub fn repeated_field(&mut self, field: &'static str) -> Vec<N>

Takes every child in repeated named field.

Source

pub fn required_matching<T>(&mut self) -> Result<N, MigrateError>
where T: Migrate<N>,

Takes a required positional child migrateible as T.

§Errors

Returns MigrateError::MissingChild when no remaining positional child can migrate T.

Source

pub fn optional_matching<T>(&mut self) -> Option<N>
where T: Migrate<N>,

Takes an optional positional child migrateible as T.

Source

pub fn repeated_matching<T>(&mut self) -> Vec<N>
where T: Migrate<N>,

Takes every positional child migrateible as T.

Source

pub fn required_anonymous( &mut self, spelling: &'static str, ) -> Result<N, MigrateError>

Takes a required anonymous delimiter or punctuation child.

§Errors

Returns MigrateError::MissingChild when the child is absent.

Source

pub fn optional_anonymous(&mut self, spelling: &'static str) -> Option<N>

Takes an optional anonymous delimiter or punctuation child.

Source

pub fn required_delimiter(&mut self) -> Result<Delimiter, MigrateError>

Migrates and consumes one of the supported delimiter pairs.

§Errors

Returns MigrateError::MissingChild when no opening delimiter or its matching closing delimiter remains.

Source

pub fn punctuated( &mut self, values: Vec<N>, spelling: &'static str, ) -> Result<Punctuated<N, N>, MigrateError>

Pairs two or more value nodes with the anonymous punctuation nodes separating them.

§Errors

Returns MigrateError::InvalidPunctuated when there are fewer than two values or the parent does not contain exactly one separator between each adjacent value.

Source

pub fn optional_punctuated( &mut self, values: Vec<N>, spelling: &'static str, ) -> Result<Option<Punctuated<N, N>>, MigrateError>

Pairs an optional punctuated field without inventing a value or a separator when the field is absent.

§Errors

Returns MigrateError::InvalidPunctuated when separators remain without values or their count does not match the present values.

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

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.