Skip to main content

Worksheet

Struct Worksheet 

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

A named sheet holding a sparse cell grid (schema spec §3).

Cell keys are plain uppercase A1 addresses (A1, BC42) — no $, no sheet qualifier, no lowercase. Absent addresses are empty cells and are never serialized. The map is ordered (BTreeMap), which matches the canonical (JCS) key order for ASCII A1 addresses: A10 sorts before A2.

The typed grid API (get / set / clear, keyed by a bounds-validated Address) is the in-memory accessor used by the recalc runtime (plan item 3.1); the raw cells map is retained for the serde layer. Address-syntax and sheet-name validation against the schema’s normative rules also happens at the serialization boundary (Workbook::from_json), independently of the typed API, since from_json parses untrusted keys.

Implementations§

Source§

impl Worksheet

Source

pub fn new(name: impl Into<String>) -> Self

Creates an empty worksheet named name.

Source

pub fn name(&self) -> &str

The sheet name, unique within a workbook (case-insensitive).

Source

pub fn cells(&self) -> &BTreeMap<String, Cell>

The sparse cell grid, keyed by plain uppercase A1 address.

Source

pub fn cells_mut(&mut self) -> &mut BTreeMap<String, Cell>

Mutable access to the sparse cell grid.

Source

pub fn get(&self, addr: Address) -> Option<&Cell>

The cell at addr, or None if that address is empty.

Source

pub fn get_mut(&mut self, addr: Address) -> Option<&mut Cell>

Mutable access to the cell at addr, or None if that address is empty.

Source

pub fn set(&mut self, addr: Address, cell: Cell) -> Option<Cell>

Writes cell at addr, returning the cell previously there (if any).

addr is already bounds-validated by construction, so a set never escapes the address bounds. To clear a cell use clear, never a set of an empty value (schema spec §4).

Source

pub fn clear(&mut self, addr: Address) -> Option<Cell>

Removes the cell at addr, returning it if present.

Clearing a cell is removing its entry, never writing an empty value: an empty entry would be byte-distinguishable from the absent cell it denotes (schema spec §4).

Source

pub fn contains(&self, addr: Address) -> bool

Whether a cell is present at addr.

Source

pub fn len(&self) -> usize

The number of populated cells.

Source

pub fn is_empty(&self) -> bool

Whether the grid has no populated cells.

Source

pub fn iter(&self) -> impl Iterator<Item = (Address, &Cell)>

Iterates the populated cells in canonical (JCS) key order, yielding the parsed Address for each. Keys held by a worksheet are always valid A1, so parsing cannot fail.

Trait Implementations§

Source§

impl Clone for Worksheet

Source§

fn clone(&self) -> Worksheet

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 Debug for Worksheet

Source§

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

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

impl<'de> Deserialize<'de> for Worksheet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for Worksheet

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Worksheet

Source§

fn eq(&self, other: &Worksheet) -> bool

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Worksheet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Worksheet

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
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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