pub trait Validate {
    fn validate_impl(&self, ctx: &mut ValidationCtx);

    fn validate(&self) -> Result<(), ValidationReport> { ... }
}
Expand description

Pre-compilation validation of tables.

The OpenType specification describes various requirements for different tables that are awkward to encode in the type system, such as requiring certain arrays to have equal lengths. These requirements are enforced via a validation pass.

Required Methods§

Validate this table.

If you need to implement this directly, it should look something like:

struct MyRecord {
    my_values: Vec<u16>,
}

impl Validate for MyRecord {
    fn validate_impl(&self, ctx: &mut ValidationCtx) {
        ctx.in_table("MyRecord", |ctx| {
            ctx.in_field("my_values", |ctx| {
                if self.my_values.len() > (u16::MAX as usize) {
                    ctx.report("array is too long");
                }
            })
        })
    }
}

Provided Methods§

Ensure that this table is well-formed, reporting any errors.

This is an auto-generated method that calls to validate_impl and collects any errors.

Implementations on Foreign Types§

Implementors§

source§

impl Validate for Post