Skip to main content

OfdModel

Trait OfdModel 

Source
pub trait OfdModel: Sized {
    // Required methods
    fn schema() -> &'static [OfdField];
    fn to_page(&self) -> OfdResult<OfdPage>;

    // Provided methods
    fn page_size() -> (f64, f64) { ... }
    fn to_pages(items: &[Self]) -> OfdResult<Vec<OfdPage>> { ... }
}
Expand description

The OfdModel trait defines the contract for Rust types that can be mapped to OFD page content.

This is the OFD equivalent of ExcelRow in easyexcel-rs. Derive it with #[derive(OfdModel)] for automatic implementation.

Required Methods§

Source

fn schema() -> &'static [OfdField]

Returns the field schema for this model.

Source

fn to_page(&self) -> OfdResult<OfdPage>

Convert this model instance into an OFD page.

§Errors

Returns an error if a field cannot be converted to a page content object.

Provided Methods§

Source

fn page_size() -> (f64, f64)

Returns the page size (width, height) in mm.

Source

fn to_pages(items: &[Self]) -> OfdResult<Vec<OfdPage>>

Convert a slice of model instances into a vec of OFD pages.

§Errors

Returns an error if any item fails conversion via to_page.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§