pub struct StyleRange { /* private fields */ }Expand description
RLE-compressed style storage for a worksheet range.
Instead of storing one Style per cell (which wastes memory when many cells share the same style), this stores:
- A palette of unique styles
- Runs of consecutive cells (row-major) that share the same style
This dramatically reduces memory usage and clone overhead for large worksheets.
Implementations§
Source§impl StyleRange
impl StyleRange
Sourcepub fn from_style_ids(
cells: Vec<(u32, u32, usize)>,
palette: Vec<Style>,
) -> Self
pub fn from_style_ids( cells: Vec<(u32, u32, usize)>, palette: Vec<Style>, ) -> Self
Create a StyleRange from style IDs and a palette (zero-copy).
This is more efficient than from_sparse as it avoids cloning styles.
cells: Vec of (row, col, style_id) where style_id indexes into palettepalette: The shared palette of unique styles (taken ownership)
Sourcepub fn from_sparse(cells: Vec<(u32, u32, Style)>) -> Self
pub fn from_sparse(cells: Vec<(u32, u32, Style)>) -> Self
Create a StyleRange from sparse cell data
Takes cells with positions and styles, compresses into RLE format.
Sourcepub fn get(&self, pos: (usize, usize)) -> Option<&Style>
pub fn get(&self, pos: (usize, usize)) -> Option<&Style>
Get style at a position (relative to range start)
Returns None if position is out of bounds, or reference to style.
Sourcepub fn cells(&self) -> StyleRangeCells<'_>
pub fn cells(&self) -> StyleRangeCells<'_>
Iterate over all cells with their positions and styles
Sourcepub fn unique_style_count(&self) -> usize
pub fn unique_style_count(&self) -> usize
Get number of unique styles (excluding empty)
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Get compression ratio (cells / runs)
Trait Implementations§
Source§impl Clone for StyleRange
impl Clone for StyleRange
Source§fn clone(&self) -> StyleRange
fn clone(&self) -> StyleRange
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StyleRange
impl Debug for StyleRange
Source§impl Default for StyleRange
impl Default for StyleRange
Source§fn default() -> StyleRange
fn default() -> StyleRange
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StyleRange
impl RefUnwindSafe for StyleRange
impl Send for StyleRange
impl Sync for StyleRange
impl Unpin for StyleRange
impl UnsafeUnpin for StyleRange
impl UnwindSafe for StyleRange
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