Skip to main content

ReportEngine

Struct ReportEngine 

Source
pub struct ReportEngine { /* private fields */ }
Expand description

Renders reports. Keep one around: it caches fonts and text measurements.

use ravenrs_report::{Band, Control, Report, ReportEngine};
use serde_json::json;

let report = Report::new("Hello").detail(Band::new(20.0).control(Control::field("[Name]").at(0.0, 0.0, 200.0, 20.0)));
let doc = ReportEngine::new().render(&report, &json!([{ "Name": "Ana" }, { "Name": "Bruno" }]));
assert_eq!(doc.pages.len(), 1);
assert!(doc.page_contains(0, "Bruno"));

Implementations§

Source§

impl ReportEngine

Source

pub fn new() -> Self

An engine with the embedded Inter font.

Source

pub fn register_function( &mut self, name: &str, function: impl Fn(&[Value]) -> Result<Value, String> + 'static, )

Adds a function to the expressions of every report this engine renders.

Source

pub fn render(&mut self, report: &Report, data: &Json) -> Document

Renders report over data with default parameters.

Source

pub fn count_rows( &self, report: &Report, data: &Json, options: &RenderOptions, ) -> usize

How many rows of data the report would print: after its data member and filter, before grouping. Lets a scheduled job skip a report with nothing in it.

Source

pub fn render_with( &mut self, report: &Report, data: &Json, options: &RenderOptions, ) -> Document

Renders report over data. Expression errors do not stop the render: they are listed in Document::errors and shown in place.

Source

pub fn text_system(&mut self) -> &mut TextSystem

The text system used for measuring, to paint documents with the same metrics.

Trait Implementations§

Source§

impl Debug for ReportEngine

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ReportEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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
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> ErasedDestructor for T
where T: 'static,

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, 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.