pub trait FontRead<'a>: Sized + ReadArgs {
// Required method
fn read_with_args(
data: FontData<'a>,
args: Self::Args,
) -> Result<Self, ReadError>;
// Provided method
fn read(data: FontData<'a>) -> Result<Self, ReadError>
where Self: FontRead<'a, Args = ()> { ... }
}Expand description
A type that can be read from raw table data.
Some types require external state in order to be read; this is passed to
read_with_args, and its type is determined by the ReadArgs
supertrait. Types that require no external state use () as their args,
and get the argument-less read constructor for free.
Required Methods§
Sourcefn read_with_args(
data: FontData<'a>,
args: Self::Args,
) -> Result<Self, ReadError>
fn read_with_args( data: FontData<'a>, args: Self::Args, ) -> Result<Self, ReadError>
Read an item, performing validation.
In the case of a table, this method is responsible for ensuring the input data is consistent: this means ensuring that any versioned fields are present as required by the version, and that any array lengths are not out-of-bounds.
If a type requires multiple arguments, they will be passed as a tuple.
You should not generally need to call this directly; it is intended to
be used from generated code. Any type that requires external arguments
also has a custom read constructor where you can pass those arguments
like normal.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".