Trait write_fonts::validate::Validate
source · pub trait Validate {
// Required method
fn validate_impl(&self, ctx: &mut ValidationCtx);
// Provided method
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§
sourcefn validate_impl(&self, ctx: &mut ValidationCtx)
fn validate_impl(&self, ctx: &mut ValidationCtx)
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§
sourcefn validate(&self) -> Result<(), ValidationReport>
fn validate(&self) -> Result<(), ValidationReport>
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.