tiger_lib::validator

Struct Validator

Source
pub struct Validator<'a> {
    block: &'a Block,
    data: &'a Everything,
    known_fields: Vec<&'a str>,
    accepted_tokens: bool,
    accepted_blocks: bool,
    accepted_block_fields: bool,
    accepted_value_fields: bool,
    case_sensitive: bool,
    allow_questionmark_equals: bool,
    max_severity: Severity,
}
Expand description

A validator for one Block. The intended usage is that you wrap the Block in a validator, then call validation functions on it until you’ve validated all the possible legitimate contents of the Block, and then the Validator will warn the user about anything left over when it goes out of scope. This way you don’t have to worry about checking for unknown fields yourself.

The validator is mostly for checking “fields” (key = value and key = { block } items in the block), but it can validate loose blocks and loose values and comparisons as well.

Fields§

§block: &'a Block

The block being validated

§data: &'a Everything

A link to all the loaded and processed CK3 and mod files

§known_fields: Vec<&'a str>

Fields that have been requested so far

§accepted_tokens: bool

Whether loose tokens are expected

§accepted_blocks: bool

Whether subblocks are expected

§accepted_block_fields: bool

Whether unknown block fields are expected

§accepted_value_fields: bool

Whether unknown value fields are expected

§case_sensitive: bool

Whether key comparisons should be done case-sensitively

§allow_questionmark_equals: bool

Whether this block can have ?= operators

§max_severity: Severity

Maximum severity of problems reported by this Validator. Defaults to Error. This is intended to be set lower by validators for less-important items. As an exception, Fatal severity reports will still always be logged as Fatal. TODO: pass this down to all the helper functions

Implementations§

Source§

impl<'a> Validator<'a>

Source

pub fn new(block: &'a Block, data: &'a Everything) -> Self

Construct a new Validator for a Block. The data reference is there to help out some of the convenience functions, and also to pass along to closures so that you can easily pass independent functions as the closures.

Source

pub fn set_case_sensitive(&mut self, cs: bool)

Control whether the fields in this Block will be matched case-sensitively or not. Whether this should be on or off depends on what the game engine allows, which is not always known.

Source

pub fn set_allow_questionmark_equals(&mut self, allow_questionmark_equals: bool)

Whether this block can contain ?= as well as = for assignments and definitions. Blocks that allow ?= are mostly specialized ones such as triggers and effects.

Source

pub fn set_max_severity(&mut self, max_severity: Severity)

Source

pub fn req_field(&mut self, name: &str) -> bool

Require field name to be present in the block, and warn if it isn’t there. Returns true iff the field is present.

Source

pub fn req_field_one_of(&mut self, names: &[&str]) -> bool

Require exactly one of the fields in names to be present in the block, and warn if they are missing or there is more than one. Returns true iff it found exactly one.

Source

pub fn req_field_warn(&mut self, name: &str) -> bool

Require field name to be present in the block, and warn if it isn’t there. Returns true iff the field is present. Warns at a lower severity than req_field.

Source

pub fn req_field_fatal(&mut self, name: &str) -> bool

Require field name to be present in the block, and warn if it isn’t there. Returns true iff the field is present. Warns at Severity::Fatal level.

Source

pub fn ban_field<F, S>(&mut self, name: &str, only_for: F)
where F: Fn() -> S, S: Borrow<str> + Display,

Require field name to not be in the block, and warn if it is found. The warning will include the output from the only_for closure, which describes where the field is expected. TODO: make lower-severity versions of this function.

Source

pub fn replaced_field(&mut self, name: &str, replaced_by: &str)

Require field name to not be in the block. If it is found, warn that it has been replaced by replaced_by. This is used to adapt to and warn about changes in the game engine.

Source

fn check_key(&mut self, name: &str) -> bool

Source

fn field_check<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &BV),

Source

fn multi_field_check<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &BV),

Source

pub fn field(&mut self, name: &str) -> bool

Expect field name, if present, to be either an assignment (= value) or a definition (= { block }). Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn multi_field(&mut self, name: &str) -> bool

Just like Validator::field, but expects any number of name fields in the block.

Source

pub fn field_any_cmp(&mut self, name: &str) -> Option<&BV>

Expect field name, if present, to be… present. Expect no more than one name field in the block. Returns the field’s BV (block or value) if the field is present. TODO: replace this with a field_validated variant.

Source

pub fn field_value(&mut self, name: &str) -> Option<&Token>

Expect field name, if present, to be an assignment (name = value). Expect no more than one name field in the block. Returns the field’s value if the field is present.

Source

pub fn field_validated_value<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, ValueValidator<'_>),

Expect field name, if present, to be an assignment (name = value). Expect no more than one name field in the block. Runs the validation closure f(key, vd) for every matching field. Returns true iff the field is present.

Source

pub fn multi_field_validated_value<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, ValueValidator<'_>),

Just like Validator::field_validated_value, but expect any number of name fields in the block.

Source

pub fn field_item(&mut self, name: &str, itype: Item) -> bool

Expect field name, if present, to be set to the key of an itype item the game database. The item is looked up and must exist. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_action(&mut self, name: &str, sc: &ScopeContext) -> bool

Expect field name, if present, to be set to the key of an on_action. The action is looked up and must exist. If it would be useful, validate the action with the given ScopeContext. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_event(&mut self, name: &str, sc: &mut ScopeContext) -> bool

Expect field name, if present, to be set to an event id. The event is looked up and must exist. If it would be useful, validate the event with the given ScopeContext. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_item_or_empty(&mut self, name: &str, itype: Item) -> bool

Expect field name, if present, to be set to the key of an itype item the game database, or be the empty string. The item is looked up and must exist. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_localization(&mut self, name: &str, sc: &mut ScopeContext) -> bool

Expect field name, if present, to be a localization key. The key is looked up and must exist. The key’s localization entry is validated using the given ScopeContext.

Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_target( &mut self, name: &str, sc: &mut ScopeContext, outscopes: Scopes, ) -> bool

Expect field name, if present, to be an assignment where the value evaluates to a scope type in outscopes.

The value is evaluated in the scope context sc, so for example if the value does scope:actor but there is no named scope “actor” in the scope context, then a warning is emitted. Also emits a warning if the value is simply “this”, because that is almost never correct.

Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn multi_field_target( &mut self, name: &str, sc: &mut ScopeContext, outscopes: Scopes, ) -> bool

Returns true iff the field is present. Just like Validator::field_target, but allows multiple fields.

Source

pub fn field_target_ok_this( &mut self, name: &str, sc: &mut ScopeContext, outscopes: Scopes, ) -> bool

Just like Validator::field_target, but allows the value to be simply “this”. It is expected to be used judiciously in cases where “this” can be correct.

Source

pub fn field_item_or_target( &mut self, name: &str, sc: &mut ScopeContext, itype: Item, outscopes: Scopes, ) -> bool

This is a combination of Validator::field_item and Validator::field_target. If the field is present and is not a known itype item, then it is evaluated as a target. Returns true iff the field is present.

Source

pub fn field_item_or_target_ok_this( &mut self, name: &str, sc: &mut ScopeContext, itype: Item, outscopes: Scopes, ) -> bool

This is a combination of Validator::field_item and Validator::field_target_ok_this. If the field is present and is not a known itype item, then it is evaluated as a target. Returns true iff the field is present.

Source

pub fn field_block(&mut self, name: &str) -> bool

Expect field name, if present, to be a definition name = { block }. Expect no more than one name field. No other validation is done. Returns true iff the field is present.

Source

pub fn field_bool(&mut self, name: &str) -> bool

Expect field name, if present, to be name = yes or name = no. Expect no more than one name field. Returns true iff the field is present.

Source

pub fn field_integer(&mut self, name: &str) -> bool

Expect field name, if present, to be set to an integer. Expect no more than one name field. Returns true iff the field is present.

Source

pub fn field_integer_range<R: RangeBounds<i64>>(&mut self, name: &str, range: R)

Expect field name, if present, to be set to an integer within the range provided. Expect no more than one name field. Returns true iff the field is present.

Source

pub fn field_numeric(&mut self, name: &str) -> bool

Expect field name, if present, to be set to a number with up to 5 decimals. (5 decimals is the limit accepted by the game engine in most contexts). Expect no more than one name field. Returns true iff the field is present.

Source

pub fn field_precise_numeric(&mut self, name: &str) -> bool

Expect field name, if present, to be set to a number with any number of decimals. Expect no more than one name field. Returns true iff the field is present.

Source

pub fn field_numeric_range_internal<R: RangeBounds<f64>>( &mut self, name: &str, range: R, precise: bool, )

Source

pub fn field_numeric_range<R: RangeBounds<f64>>(&mut self, name: &str, range: R)

Expect field name, if present, to be set to a number within the range provided. Accept at most 5 decimals. (5 decimals is the limit accepted by the game engine in most contexts). Expect no more than one name field.

Source

pub fn field_precise_numeric_range<R: RangeBounds<f64>>( &mut self, name: &str, range: R, )

Expect field name, if present, to be set to a number within the range provided. Expect no more than one name field.

Source

pub fn field_date(&mut self, name: &str) -> bool

Expect field name, if present, to be set to a date. The format of dates is very flexible, from a single number (the year), to a year.month or year.month.day. No checking is done on the validity of the date as a date (so January 42nd is okay). Expect no more than one name field. Returns true iff the field is present.

Source

pub fn field_trigger_full<'b, T>( &mut self, name: &str, fsc: T, tooltipped: Tooltipped, ) -> bool
where T: Into<FieldScopeContext<'b>>,

Expect field name, if present, to be set to a trigger block.

The scope context may be a full ScopeContext, a rooted Scopes or a closure that builds one from the field key token.

Source

pub fn field_effect_full<'b, T>( &mut self, name: &str, fsc: T, tooltipped: Tooltipped, ) -> bool
where T: Into<FieldScopeContext<'b>>,

Expect field name, if present, to be set to an effect block.

The scope context may be a full ScopeContext, a rooted Scopes or a closure that builds one from the field key token.

Source

pub fn field_script_value_full<'b, T>( &mut self, name: &str, fsc: T, breakdown: bool, ) -> bool
where T: Into<FieldScopeContext<'b>>,

Epexect field name, if present, to be set to a script value.

The scope context may be a full ScopeContext, a rooted Scopes or a closure that builds one from the field key token.

If breakdown is true, it does not warn if it is an inline script value and the desc fields in it do not contain valid localizations. This is generally used for script values that will never be shown to the user except in debugging contexts, such as ai_will_do.

Source

pub fn field_script_value(&mut self, name: &str, sc: &mut ScopeContext) -> bool

Expect field name, if present, to be set to a script value, either a named one (simply name = scriptvaluename) or an inline one (can be a simple number, or a range { min max }, or a full script value definition with limits and math).

The script value is evaluated in the scope context sc, so for example if the script value does scope:actor but there is no named scope “actor” in the scope context, then a warning is emitted.

Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_script_value_build_sc<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token) -> ScopeContext,

Just like Validator::field_script_value, but it takes a closure that uses the field key token as the input to build and output a ScopeContext. This is a convenient way to associate the root type with the key of this field, for clearer warnings. A passed-in ScopeContext would have to be associated with a key that is further away.

Source

pub fn field_script_value_no_breakdown_build_sc<F>( &mut self, name: &str, f: F, ) -> bool
where F: FnMut(&Token) -> ScopeContext,

Just like Validator::field_script_value, but it takes a closure that uses the field key token as the input to build and output a ScopeContext. This is a convenient way to associate the root type with the key of this field, for clearer warnings. A passed-in ScopeContext would have to be associated with a key that is further away.

Does not warn if it is an inline script value and the desc fields in it do not contain valid localizations.

Source

pub fn fields_script_value(&mut self, name: &str, sc: &mut ScopeContext) -> bool

Just like Validator::field_script_value, but it it expects any number of name fields.

Source

pub fn field_choice(&mut self, name: &str, choices: &[&str]) -> bool

Expect field name, if present, to be set to one of the listed strings in choices. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn multi_field_choice(&mut self, name: &str, choices: &[&str]) -> bool

Just like Validator::field_choice, but expect any number of name fields in the block.

Source

pub fn field_list(&mut self, name: &str) -> bool

Expect field name, if present, to be of the form name = { value value value ... } with any number of values. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_validated_list<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &Everything),

Expect field name, if present, to be of the form name = { value value value ... } with any number of values. Expect no more than one name field in the block. Calls the closure f(value, data) for every value in the list. Returns true iff the field is present.

Source

pub fn field_list_items(&mut self, name: &str, item: Item) -> bool

Expect field name, if present, to be of the form name = { value value value ... } with any number of values. Expect every value to be an itype item in the game database. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_list_choice(&mut self, name: &str, choices: &[&str]) -> bool

Expect field name, if present, to be of the form name = { value value value ... } with any number of values. Expect every value to be an entry from the choices array. Expect no more than one name field in the block. Returns true iff the field is present.

Source

pub fn field_icon(&mut self, name: &str, define: &str, suffix: &str) -> bool

Source

pub fn multi_field_validated_list<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &Everything),

Just like Validator::field_validated_list, but expect any number of name fields in the block.

Source

pub fn multi_field_list_items(&mut self, name: &str, item: Item) -> bool

Just like Validator::field_list_items, but expect any number of name fields in the block.

Source

pub fn multi_field_value(&mut self, name: &str) -> Vec<&Token>

Just like Validator::field_value, but expect any number of name fields in the block.

Source

pub fn multi_field_item(&mut self, name: &str, itype: Item)

Just like Validator::field_item, but expect any number of name fields in the block.

Source

pub fn multi_field_any_cmp(&mut self, name: &str) -> bool

Just like Validator::field_any_cmp, but expect any number of name fields in the block.

Source

pub fn field_validated<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&BV, &Everything),

Expect field name, if present, to be either an assignment (= value) or a definition (= { block }). Expect no more than one name field in the block. Calls the closure f(bv, data) for every matching field. Returns true iff the field is present.

Source

pub fn field_validated_key<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &BV, &Everything),

Just like Validator::field_validated, but the closure is f(key, bv, data).

Source

pub fn field_validated_sc<F>( &mut self, name: &str, sc: &mut ScopeContext, f: F, ) -> bool
where F: FnMut(&BV, &Everything, &mut ScopeContext),

Just like Validator::field_validated, but the closure is f(bv, data, sc) where sc is the passed-in ScopeContext.

This method is useful for delegating to validate_desc which takes a bv and a sc.

Source

pub fn field_validated_rooted<F>( &mut self, name: &str, scopes: Scopes, f: F, ) -> bool
where F: FnMut(&BV, &Everything, &mut ScopeContext),

Just like Validator::field_validated_sc, but instead of a full ScopeContext it just gets the scope type to be used for the root of a ScopeContext that is made on the spot. This is a convenient way to associate the root type with the key of this field, for clearer warnings. A passed-in ScopeContext would have to be associated with a key that is further away.

Source

pub fn field_validated_build_sc<B, F>(&mut self, name: &str, b: B, f: F) -> bool
where B: FnMut(&Token) -> ScopeContext, F: FnMut(&BV, &Everything, &mut ScopeContext),

Source

pub fn multi_field_validated<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&BV, &Everything),

Just like Validator::field_validated, but expect any number of name fields in the block.

Source

pub fn multi_field_validated_key<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &BV, &Everything),

Just like Validator::field_validated_key, but expect any number of name fields in the block.

Source

pub fn multi_field_validated_sc<F>( &mut self, name: &str, sc: &mut ScopeContext, f: F, ) -> bool
where F: FnMut(&BV, &Everything, &mut ScopeContext),

Just like Validator::field_validated_sc, but expect any number of name fields in the block.

Source

pub fn multi_field_validated_block<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Block, &Everything),

Just like Validator::field_validated_block, but expect any number of name fields in the block.

Source

pub fn multi_field_validated_block_sc<F>( &mut self, name: &str, sc: &mut ScopeContext, f: F, ) -> bool
where F: FnMut(&Block, &Everything, &mut ScopeContext),

Just like Validator::field_validated_block_sc, but expect any number of name fields in the block.

Source

pub fn field_validated_block<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Block, &Everything),

Expect field name, if present, to be a definition name = { block }. Expect no more than one name field in the block. Calls the closure f(block, data) for every matching field. Returns true iff the field is present.

Source

pub fn field_validated_key_block<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &Block, &Everything),

Just like Validator::field_validated_block, but the closure is f(key, block, data).

Source

pub fn field_validated_block_build_sc<B, F>( &mut self, name: &str, b: B, f: F, ) -> bool

Source

pub fn multi_field_validated_key_block<F>(&mut self, name: &str, f: F) -> bool
where F: FnMut(&Token, &Block, &Everything),

Just like Validator::field_validated_key_block, but expect any number of name fields in the block.

Source

pub fn field_validated_block_sc<F>( &mut self, name: &str, sc: &mut ScopeContext, f: F, ) -> bool
where F: FnMut(&Block, &Everything, &mut ScopeContext),

Just like Validator::field_validated_block, but the closure is f(block, data, sc) where sc is the passed-in ScopeContext.

Source

pub fn field_validated_block_rooted<F>( &mut self, name: &str, scopes: Scopes, f: F, ) -> bool
where F: FnMut(&Block, &Everything, &mut ScopeContext),

Just like Validator::field_validated_block_sc, but instead of a full ScopeContext it just gets the scope type to be used for the root of a ScopeContext that is made on the spot. This is a convenient way to associate the root type with the key of this field, for clearer warnings. A passed-in ScopeContext would have to be associated with a key that is further away.

Source

pub fn multi_field_validated_block_rooted<F>( &mut self, name: &str, scopes: Scopes, f: F, )
where F: FnMut(&Block, &Everything, &mut ScopeContext),

Just like Validator::field_validated_block_rooted, but expect any number of name fields in the block.

Source

pub fn field_validated_block_rerooted<F>( &mut self, name: &str, sc: &ScopeContext, scopes: Scopes, f: F, ) -> bool
where F: FnMut(&Block, &Everything, &mut ScopeContext),

Just like Validator::field_validated_block_rooted, but it takes the passed-in ScopeContext and associates its root with this field’s key instead of whatever it was associated with before. This is purely to get better warnings.

TODO: get rid of this in favor of making proper ScopeContext to begin with.

Source

pub fn multi_field_block(&mut self, name: &str) -> bool

Just like Validator::field_block, but expect any number of name fields in the block.

Source

pub fn req_tokens_integers_exactly(&mut self, expect: usize)

Expect this Block to be a block with exactly expect loose values that are integers. So it’s of the form { 1 2 3 }.

Source

pub fn req_tokens_numbers_exactly(&mut self, expect: usize)

Expect this Block to be a block with exactly expect loose values that are numeric with up to 5 decimals. So it’s of the form { 0.0 0.5 1.0 }

Source

pub fn field_list_numeric_exactly(&mut self, name: &str, expect: usize)

Expect field name, if present, to be of the form name = { value value value ... } with exactly expect values. Expect every value to be a number with up to 5 decimals. Expect no more than one name field in the block.

Source

pub fn req_tokens_precise_numbers_exactly(&mut self, expect: usize)

Like Validator::req_tokens_numbers_exactly but the numbers can have any number of decimals.

Source

pub fn field_list_precise_numeric_exactly(&mut self, name: &str, expect: usize)

Like Validator::field_list_numeric_exactly but the numbers can have any number of decimals.

Source

pub fn field_list_integers_exactly(&mut self, name: &str, expect: usize)

Like Validator::field_list_numeric_exactly but the numbers have to be integers.

Source

pub fn values(&mut self) -> Vec<&Token>

Expect the block to contain any number of loose values (possibly in addition to other things). Return a vector of those values. TODO: make this take a closure or make it an iterator.

Source

pub fn blocks(&mut self) -> Vec<&Block>

Expect the block to contain any number of loose sub-blocks (possibly in addition to other things). Return a vector of those blocks. TODO: make callers use validated_blocks instead.

Source

pub fn validated_blocks<F>(&mut self, f: F)
where F: FnMut(&Block, &Everything),

Expect the block to contain any number of loose sub-blocks (possibly in addition to other things). Run the closure f(block, data) for every sub-block.

Source

pub fn integer_blocks(&mut self) -> Vec<(&Token, &Block)>

Expect the block to contain any number of key = { block } fields where the key is an integer. Return them as a vector of (key, block) pairs. TODO: make this take a closure.

Source

pub fn integer_values(&mut self) -> Vec<(&Token, &Token)>

Expect the block to contain any number of key = value fields where the key is an integer. Return them as a vector of (key, value) pairs. TODO: make this take a closure.

Source

pub fn integer_keys<F: FnMut(&Token, &BV)>(&mut self, f: F)

Expect the block to contain any number of key = value or key = { block } fields where the key is an integer. Return them as a vector of (key, bv) pairs. TODO: make this take a closure.

Source

pub fn numeric_keys<F: FnMut(&Token, &BV)>(&mut self, f: F)

Expect the block to contain any number of key = value or key = { block } fields where the key is a number with up to 5 decimals. Return them as a vector of (key, bv) pairs. TODO: make this take a closure.

Source

pub fn validate_history_blocks<F>(&mut self, f: F)
where F: FnMut(Date, &Token, &Block, &Everything),

Expect the block to contain any number of key = { block } fields where the key is a date. Run the closure f(date, block, data) for every matching field.

Source

fn validate_item_key_fields<F>(&mut self, itype: Item, f: F)
where F: FnMut(&Token, &BV, &Everything),

Expect the block to contain any number of key = value or key = { block }fields where each key is a unique Item of type itype. Run the closure f(key, bv, data) for every matching block.

Source

pub fn validate_item_key_values<F>(&mut self, itype: Item, f: F)
where F: FnMut(&Token, ValueValidator<'_>),

Expect the block to contain any number of key = value fields where each key is a unique Item of type itype. Run the closure f(key, vd) for every matching block.

Source

pub fn validate_item_key_blocks<F>(&mut self, itype: Item, f: F)
where F: FnMut(&Token, &Block, &Everything),

Expect the block to contain any number of key = { block } fields where each key is a unique Item of type itype. Run the closure f(key, block, data) for every matching block.

Source

pub fn unknown_fields<F: FnMut(&Token, &BV)>(&mut self, f: F)

Expect the block to contain any number of unknown fields (so don’t warn about unknown fields anymore). Loose values and loose sub-blocks will still be warned about. Run the closure f(key, bv) on every matching unknown field. Previously-validated fields will be skipped.

Source

pub fn unknown_block_fields<F: FnMut(&Token, &Block)>(&mut self, f: F)

Expect the block to contain any number of unknown key = { block } fields. Run the closure f(key, block) on every matching unknown field. Previously-validated fields will be skipped.

Source

pub fn unknown_value_fields<F: FnMut(&Token, &Token)>(&mut self, f: F)

Expect the block to contain any number of unknown key = value fields. Run the closure f(key, value) on every matching unknown field. Previously-validated fields will be skipped.

Source

pub fn unknown_fields_cmp<F: FnMut(&Token, Comparator, &BV)>(&mut self, f: F)

Like Validator::unknown_fields but passes the comparator, so that f can determine whether it is = or ?= It still expects the comparator to be one of those two.

Source

pub fn unknown_fields_any_cmp<F: FnMut(&Token, Comparator, &BV)>( &mut self, f: F, )

Like Validator::unknown_fields_cmp but accepts and passes any comparator.

Source

pub fn no_warn_remaining(&mut self)

Tells the Validator to not warn about any unknown block contents when it goes out of scope. (The default is to warn.)

Source

pub fn warn_remaining(&mut self) -> bool

Tells the Validator to warn about any unknown block contents right now, before it goes out of scope. It will not warn again when it does go out of scope. Returns true iff any warnings were emitted.

Source

fn expect_eq_qeq(&self, key: &Token, cmp: Comparator)

Trait Implementations§

Source§

impl Debug for Validator<'_>

Source§

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

Roll our own Debug implementation in order to leave out the data field.

Source§

impl Drop for Validator<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Validator<'a>

§

impl<'a> !RefUnwindSafe for Validator<'a>

§

impl<'a> Send for Validator<'a>

§

impl<'a> Sync for Validator<'a>

§

impl<'a> Unpin for Validator<'a>

§

impl<'a> !UnwindSafe for Validator<'a>

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
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

§

fn type_name(&self) -> &'static str

Gets the type name of self
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
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> Downcast for T
where T: AsAny + ?Sized,

§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.