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>
impl<N: ExternalCstNode> ChildCursor<N>
Sourcepub fn new(parent: &N) -> Self
pub fn new(parent: &N) -> Self
Collects the children of parent for single-pass field selection.
Sourcepub fn required_field(&mut self, field: &'static str) -> Result<N, MigrateError>
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.
Sourcepub fn optional_field(&mut self, field: &'static str) -> Option<N>
pub fn optional_field(&mut self, field: &'static str) -> Option<N>
Takes the child in optional named field.
Sourcepub fn repeated_field(&mut self, field: &'static str) -> Vec<N>
pub fn repeated_field(&mut self, field: &'static str) -> Vec<N>
Takes every child in repeated named field.
Sourcepub fn required_matching<T>(&mut self) -> Result<N, MigrateError>where
T: Migrate<N>,
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.
Sourcepub fn optional_matching<T>(&mut self) -> Option<N>where
T: Migrate<N>,
pub fn optional_matching<T>(&mut self) -> Option<N>where
T: Migrate<N>,
Takes an optional positional child migrateible as T.
Sourcepub fn repeated_matching<T>(&mut self) -> Vec<N>where
T: Migrate<N>,
pub fn repeated_matching<T>(&mut self) -> Vec<N>where
T: Migrate<N>,
Takes every positional child migrateible as T.
Sourcepub fn required_anonymous(
&mut self,
spelling: &'static str,
) -> Result<N, MigrateError>
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.
Sourcepub fn optional_anonymous(&mut self, spelling: &'static str) -> Option<N>
pub fn optional_anonymous(&mut self, spelling: &'static str) -> Option<N>
Takes an optional anonymous delimiter or punctuation child.
Sourcepub fn required_delimiter(&mut self) -> Result<Delimiter, MigrateError>
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.
Sourcepub fn punctuated(
&mut self,
values: Vec<N>,
spelling: &'static str,
) -> Result<(N, Vec<(N, N)>), MigrateError>
pub fn punctuated( &mut self, values: Vec<N>, spelling: &'static str, ) -> Result<(N, Vec<(N, N)>), MigrateError>
Pairs a nonempty list of migrated value nodes with the anonymous punctuation nodes separating them.
§Errors
Returns MigrateError::InvalidPunctuated when there is no first
value or the parent does not contain exactly one separator between each
adjacent value.
Sourcepub fn optional_punctuated(
&mut self,
values: Vec<N>,
spelling: &'static str,
) -> Result<Option<(N, Vec<(N, N)>)>, MigrateError>
pub fn optional_punctuated( &mut self, values: Vec<N>, spelling: &'static str, ) -> Result<Option<(N, Vec<(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.