Skip to main content

Table

Struct Table 

Source
#[non_exhaustive]
pub struct Table { pub rows: Vec<TableRow>, pub width: Option<HwpUnit>, pub caption: Option<Caption>, pub page_break: TablePageBreak, pub repeat_header: bool, pub cell_spacing: Option<HwpUnit>, pub border_fill_id: Option<u32>, }
Expand description

A table: a sequence of rows, with optional width and caption.

§Design Decision

No border: Option<BorderStyle> in Phase 1. Border styling is a Blueprint concern (Phase 2). Core tables are purely structural.

§Examples

use hwpforge_core::table::{Table, TableCell, TablePageBreak, TableRow};
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{HwpUnit, ParaShapeIndex};

let table = Table::new(vec![TableRow::new(vec![TableCell::new(
    vec![Paragraph::new(ParaShapeIndex::new(0))],
    HwpUnit::from_mm(100.0).unwrap(),
)])])
.with_page_break(TablePageBreak::Cell);
assert_eq!(table.row_count(), 1);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§rows: Vec<TableRow>

Rows of the table.

§width: Option<HwpUnit>

Optional explicit table width. None means auto-width.

§caption: Option<Caption>

Optional table caption.

§page_break: TablePageBreak

Page-break policy for this table.

§repeat_header: bool

Whether the first row repeats across page breaks.

§cell_spacing: Option<HwpUnit>

Optional explicit spacing between table cells.

§border_fill_id: Option<u32>

Optional table-level border/fill reference.

Implementations§

Source§

impl Table

Source

pub fn new(rows: Vec<TableRow>) -> Self

Creates a table from rows.

§Examples
use hwpforge_core::table::{Table, TableRow};

let table = Table::new(vec![TableRow::new(vec![])]);
assert_eq!(table.row_count(), 1);
Source

pub fn with_width(self, width: HwpUnit) -> Self

Sets an explicit table width.

Source

pub fn with_caption(self, caption: Caption) -> Self

Attaches a table caption.

Source

pub fn with_page_break(self, page_break: TablePageBreak) -> Self

Sets the page-break policy for this table.

Source

pub fn with_repeat_header(self, repeat_header: bool) -> Self

Controls whether the leading header block repeats across page breaks.

Source

pub fn with_cell_spacing(self, cell_spacing: HwpUnit) -> Self

Sets the explicit spacing between cells.

Source

pub fn with_border_fill_id(self, border_fill_id: u32) -> Self

Sets the table-level border/fill reference.

Source

pub fn row_count(&self) -> usize

Returns the number of rows.

Source

pub fn col_count(&self) -> usize

Returns the number of columns (from the first row).

Returns 0 if the table has no rows.

Source

pub fn is_empty(&self) -> bool

Returns true if the table has no rows.

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Table

Source§

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

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

impl<'de> Deserialize<'de> for Table

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 Display for Table

Source§

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

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

impl JsonSchema for Table

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Table

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Table

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 Table

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,