Skip to main content

Range

Struct Range 

Source
pub struct Range<'a> { /* private fields */ }
Expand description

A rectangular, calamine-style view over a worksheet’s effective cells.

Range is built from a Sheet using Excel’s last-write-wins semantics for duplicate coordinates. Positions passed to Range::get are relative to the range start; absolute positions are available from Range::used_cells_abs.

Implementations§

Source§

impl<'a> Range<'a>

Source

pub fn new(start: (u32, u32), end: (u32, u32)) -> Self

Construct a rectangular sparse range with no populated cells.

The positions use absolute worksheet coordinates. rxls stores worksheet columns as u16, so columns outside that grid panic instead of silently changing the requested rectangle.

§Panics

Panics if start is after end, or if either column is outside rxls’ worksheet grid.

Source

pub fn empty() -> Self

Construct an empty range.

rxls represents missing worksheet positions as None in range APIs, so an empty range has no rectangular bounds and iterates no cells.

Source

pub fn from_sparse<I, V>(cells: I) -> Self
where I: IntoIterator<Item = ((u32, u32), V)>, V: Into<Cell>,

Construct a range from sparse owned cells.

The input positions use absolute worksheet coordinates. The resulting range bounds are the minimum rectangular area covering all supplied cells, while missing positions remain None in rxls’ sparse facade.

§Panics

Panics if any column is outside rxls’ worksheet grid.

Source

pub fn set_value(&mut self, pos: (u32, u32), value: impl Into<Cell>)

Set a cell value at an absolute worksheet position.

If the position extends beyond the current bottom-right bound, the range grows to include it. Positions above or left of an existing range start panic, matching calamine’s Range::set_value contract while preserving rxls’ sparse None representation for other missing cells.

§Panics

Panics if pos is above or left of an existing range start, or if the column is outside rxls’ worksheet grid.

Source

pub fn is_empty(&self) -> bool

true when the range contains no cells.

Source

pub fn start(&self) -> Option<(u32, u32)>

Absolute (row, col) of the top-left cell in the used rectangle.

Source

pub fn end(&self) -> Option<(u32, u32)>

Absolute (row, col) of the bottom-right cell in the used rectangle.

Source

pub fn dimensions_info(&self) -> Option<Dimensions>

Inclusive dimensions of the used rectangle.

Source

pub fn height(&self) -> usize

Number of rows in the used rectangle.

Source

pub fn width(&self) -> usize

Number of columns in the used rectangle.

Source

pub fn size(&self) -> (usize, usize)

Size of the used rectangle as (height, width).

Source

pub fn get_size(&self) -> (usize, usize)

Alias for Range::size, matching calamine naming.

Source

pub fn range(&self, start: (u32, u32), end: (u32, u32)) -> Self

Build a new rectangular subrange from absolute worksheet coordinates.

This mirrors calamine’s Range::range shape while preserving rxls’ sparse representation: positions without a cell remain None in Range::rows and Range::cells.

Source

pub fn get(&self, pos: (usize, usize)) -> Option<&Cell>

Get a cell by relative (row, col) within the range.

Source

pub fn get_abs(&self, row: u32, col: u16) -> Option<&Cell>

Get a cell by absolute worksheet (row, col).

Source

pub fn get_value(&self, pos: (u32, u32)) -> Option<&Cell>

Get a cell by absolute worksheet (row, col), matching calamine’s Range::get_value naming. Columns outside this crate’s u16 grid return None.

Source

pub fn formatted(&self, pos: (usize, usize)) -> Option<&str>

Get a cell’s formatted display text by relative (row, col) within the range.

Source

pub fn formatted_abs(&self, row: u32, col: u16) -> Option<&str>

Get a cell’s formatted display text by absolute worksheet (row, col).

Source

pub fn headers(&self) -> Option<Vec<String>>

First rectangular row as display strings, suitable for serde headers. Missing sparse cells are represented as empty strings.

Source

pub fn rows( &self, ) -> impl DoubleEndedIterator<Item = Vec<Option<&Cell>>> + ExactSizeIterator + FusedIterator + '_

Iterate rectangular rows from top to bottom.

Each row contains one entry per column in the used rectangle. Missing sparse cells are represented as None.

Source

pub fn row_views(&self) -> RangeRows<'_, 'a>

Iterate borrowed row views from top to bottom without allocating one Vec per row.

Source

pub fn used_cells( &self, ) -> impl DoubleEndedIterator<Item = (u32, u16, &Cell)> + ExactSizeIterator + FusedIterator + '_

Iterate the non-empty effective cells as relative (row, col, cell).

Coordinates are zero-based offsets from Range::start, matching calamine’s Range::used_cells semantics. Use Range::used_cells_abs when worksheet-absolute coordinates are needed.

Source

pub fn used_cells_abs( &self, ) -> impl DoubleEndedIterator<Item = (u32, u16, &Cell)> + ExactSizeIterator + FusedIterator + '_

Iterate the non-empty effective cells as absolute worksheet (row, col, cell).

Source

pub fn cells( &self, ) -> impl DoubleEndedIterator<Item = (usize, usize, Option<&Cell>)> + ExactSizeIterator + FusedIterator + '_

Iterate every rectangular cell position as (relative_row, relative_col, cell). Missing sparse cells are represented as None.

Source

pub fn deserialize<D>(&'a self) -> Result<RangeDeserializer<'a, D>, DeError>
where D: Deserialize<'a>,

Build a typed row deserializer with the default header-row behavior.

Trait Implementations§

Source§

impl<'a> Clone for Range<'a>

Source§

fn clone(&self) -> Range<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Range<'a>

Source§

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

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

impl<'a> Default for Range<'a>

Source§

fn default() -> Range<'a>

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

impl<'left, 'right> PartialEq<Range<'right>> for Range<'left>

Source§

fn eq(&self, other: &Range<'right>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Range<'a>

§

impl<'a> RefUnwindSafe for Range<'a>

§

impl<'a> Send for Range<'a>

§

impl<'a> Sync for Range<'a>

§

impl<'a> Unpin for Range<'a>

§

impl<'a> UnsafeUnpin for Range<'a>

§

impl<'a> UnwindSafe for Range<'a>

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.