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
impl ReportEngine
Sourcepub fn register_function(
&mut self,
name: &str,
function: impl Fn(&[Value]) -> Result<Value, String> + 'static,
)
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.
Sourcepub fn render(&mut self, report: &Report, data: &Json) -> Document
pub fn render(&mut self, report: &Report, data: &Json) -> Document
Renders report over data with default parameters.
Sourcepub fn count_rows(
&self,
report: &Report,
data: &Json,
options: &RenderOptions,
) -> usize
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.
Sourcepub fn render_with(
&mut self,
report: &Report,
data: &Json,
options: &RenderOptions,
) -> Document
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.
Sourcepub fn text_system(&mut self) -> &mut TextSystem
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
impl Debug for ReportEngine
Auto Trait Implementations§
impl !Freeze for ReportEngine
impl !RefUnwindSafe for ReportEngine
impl !Send for ReportEngine
impl !Sync for ReportEngine
impl !UnwindSafe for ReportEngine
impl Unpin for ReportEngine
impl UnsafeUnpin for ReportEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more