Skip to main content

LazySlideSource

Trait LazySlideSource 

Source
pub trait LazySlideSource {
    // Required methods
    fn slide_count(&self) -> usize;
    fn generate_slide(&self, index: usize) -> Option<SlideContent>;

    // Provided methods
    fn slide_features(&self, index: usize) -> Option<(bool, usize)> { ... }
    fn slide_has_notes(&self, index: usize) -> bool { ... }
    fn slide_chart_count(&self, index: usize) -> usize { ... }
}
Expand description

Lazy slide source - allows generating slides on-demand instead of all at once. This is useful for:

  • Very large presentations that don’t fit in memory
  • Dynamically generated slide content
  • Streaming data sources

§Example

use std::fs::File;
use ppt_rs::{create_pptx_lazy_to_writer, LazySlideSource, SlideContent};

struct MySlideGenerator {
    count: usize,
}

impl LazySlideSource for MySlideGenerator {
    fn slide_count(&self) -> usize {
        self.count
    }

    fn generate_slide(&self, index: usize) -> Option<SlideContent> {
        if index < self.count {
            Some(SlideContent::new(&format!("Slide {}", index + 1))
                .add_bullet(&format!("Content {}", index + 1)))
        } else {
            None
        }
    }
}

let file = File::create("output.pptx")?;
create_pptx_lazy_to_writer(file, "My Presentation", Box::new(MySlideGenerator { count: 100 }), None)?;

Required Methods§

Source

fn slide_count(&self) -> usize

Return the total number of slides

Source

fn generate_slide(&self, index: usize) -> Option<SlideContent>

Generate a slide by index (0-based). Return None if index is out of bounds.

Provided Methods§

Source

fn slide_features(&self, index: usize) -> Option<(bool, usize)>

Notes and chart count from a single slide generation when both are needed.

Source

fn slide_has_notes(&self, index: usize) -> bool

Check if a slide has notes (default implementation checks the generated slide)

Source

fn slide_chart_count(&self, index: usize) -> usize

Get the number of charts in a slide (default implementation checks the generated slide)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§