krilla 0.7.0

A high-level crate for creating PDF files.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
use std::marker::PhantomData;
use std::num::{NonZeroU16, NonZeroU32};

use smallvec::SmallVec;

use crate::geom::Rect;
use crate::surface::Location;

include!("generated.rs");

impl TagKind {
    /// Get the location.
    pub fn location(&self) -> Option<Location> {
        self.as_any().location
    }

    /// Set the location.
    pub fn set_location(&mut self, location: Option<Location>) {
        self.as_any_mut().location = location;
    }

    /// Set the location.
    pub fn with_location(mut self, location: Option<Location>) -> Self {
        self.as_any_mut().location = location;
        self
    }
}

/// A specific tag which allows accessing attributes specific to this [`TagKind`].
///
/// # Example
/// ```
/// use std::num::NonZeroU32;
/// use krilla::tagging::{TagGroup, TagTree, TableHeaderScope, Tag, TagId};
///
/// let tag = Tag::TH(TableHeaderScope::Row)
///     .with_id(Some(TagId::from(*b"this id")))
///     .with_col_span(Some(NonZeroU32::new(3).unwrap()))
///     .with_headers(Some([TagId::from(*b"parent id")]))
///     .with_width(Some(250.0))
///     .with_height(Some(100.0));
/// let group = TagGroup::new(tag);
///
/// let mut tree = TagTree::new();
/// tree.push(group);
/// ```
#[derive(Clone, Debug, PartialEq)]
pub struct Tag<T> {
    inner: AnyTag,
    /// Compile time marker for a type-safe API.
    pub(crate) ty: PhantomData<T>,
}

impl<T> Tag<T> {
    /// This can't be public, otherwise tags could be constructed without
    /// providing required attributes.
    pub(crate) const fn new() -> Self {
        Self {
            inner: AnyTag::new(),
            ty: PhantomData,
        }
    }

    /// A raw tag, which allows reading all attributes.
    pub fn as_any(&self) -> &AnyTag {
        &self.inner
    }

    /// A raw tag, which allows reading all attributes and additionally writing
    /// all global ones.
    pub fn as_any_mut(&mut self) -> &mut AnyTag {
        &mut self.inner
    }

    /// Get the location.
    pub fn location(&self) -> Option<Location> {
        self.as_any().location
    }

    /// Set the location.
    pub fn set_location(&mut self, location: Option<Location>) {
        self.as_any_mut().location = location;
    }

    /// Set the location.
    pub fn with_location(mut self, location: Option<Location>) -> Self {
        self.as_any_mut().location = location;
        self
    }
}

/// A raw tag, which allows reading all attributes and additionally writing all
/// global ones.
#[derive(Clone, Debug, PartialEq)]
pub struct AnyTag {
    /// The location of the tag.
    pub location: Option<Location>,
    pub(crate) attrs: OrdinalSet<Attr>,
}

impl AnyTag {
    pub(crate) const fn new() -> Self {
        Self {
            attrs: OrdinalSet::new(),
            location: None,
        }
    }
}

/// An ordered set using ordinal numbers to sort and identify elements.
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct OrdinalSet<A> {
    items: SmallVec<[A; 1]>,
}

impl<A> OrdinalSet<A> {
    pub(crate) const fn new() -> Self {
        Self {
            items: SmallVec::new_const(),
        }
    }
}

impl<A: Ordinal> OrdinalSet<A> {
    pub(crate) fn iter(&self) -> impl Iterator<Item = &A> {
        self.items.iter()
    }

    pub(crate) fn set(&mut self, attr: A) {
        for (i, item) in self.items.iter().enumerate() {
            if item.ordinal() == attr.ordinal() {
                self.items[i] = attr;
                return;
            }
            if item.ordinal() > attr.ordinal() {
                self.items.insert(i, attr);
                return;
            }
        }
        self.items.push(attr);
    }

    pub(crate) fn remove(&mut self, ordinal: usize) {
        for (i, item) in self.items.iter().enumerate() {
            if item.ordinal() == ordinal {
                self.items.remove(i);
                return;
            }
            if item.ordinal() > ordinal {
                break;
            }
        }
    }

    pub(crate) fn get(&self, ordinal: usize) -> Option<&A> {
        for item in self.items.iter() {
            if item.ordinal() == ordinal {
                return Some(item);
            }
            if item.ordinal() > ordinal {
                break;
            }
        }
        None
    }

    pub(crate) fn set_or_remove(&mut self, ordinal: usize, attr: Option<A>) {
        match attr {
            Some(attr) => self.set(attr),
            None => self.remove(ordinal),
        }
    }
}

/// Identifies elements using an ordinal number.
pub(crate) trait Ordinal {
    fn ordinal(&self) -> usize;
}

/// An identifier of a [`Tag`].
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct TagId(pub(crate) SmallVec<[u8; 16]>);

impl<I: IntoIterator<Item = u8>> From<I> for TagId {
    fn from(value: I) -> Self {
        // Disambiguate ids provided by the user from ids automatically assigned
        // to notes by prefixing them with a `U`.
        let bytes = std::iter::once(b'U').chain(value).collect();
        TagId(bytes)
    }
}

impl TagId {
    /// Returns the identifier as a byte slice.
    pub fn as_bytes(&self) -> &[u8] {
        self.0.as_slice()
    }
}

/// The list numbering type.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum ListNumbering {
    /// No numbering.
    None,
    /// Solid circular bullets.
    Disc,
    /// Open circular bullets.
    Circle,
    /// Solid square bullets.
    Square,
    /// Decimal numbers.
    Decimal,
    /// Lowercase Roman numerals.
    LowerRoman,
    /// Uppercase Roman numerals.
    UpperRoman,
    /// Lowercase letters.
    LowerAlpha,
    /// Uppercase letters.
    UpperAlpha,
}

impl ListNumbering {
    pub(crate) fn to_pdf(self) -> pdf_writer::types::ListNumbering {
        match self {
            ListNumbering::None => pdf_writer::types::ListNumbering::None,
            ListNumbering::Disc => pdf_writer::types::ListNumbering::Disc,
            ListNumbering::Circle => pdf_writer::types::ListNumbering::Circle,
            ListNumbering::Square => pdf_writer::types::ListNumbering::Square,
            ListNumbering::Decimal => pdf_writer::types::ListNumbering::Decimal,
            ListNumbering::LowerRoman => pdf_writer::types::ListNumbering::LowerRoman,
            ListNumbering::UpperRoman => pdf_writer::types::ListNumbering::UpperRoman,
            ListNumbering::LowerAlpha => pdf_writer::types::ListNumbering::LowerAlpha,
            ListNumbering::UpperAlpha => pdf_writer::types::ListNumbering::UpperAlpha,
        }
    }
}

/// The scope of a table header cell.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum TableHeaderScope {
    /// The header cell refers to the row.
    Row,
    /// The header cell refers to the column.
    Column,
    /// The header cell refers to both the row and the column.
    Both,
}

impl TableHeaderScope {
    pub(crate) fn to_pdf(self) -> pdf_writer::types::TableHeaderScope {
        match self {
            TableHeaderScope::Row => pdf_writer::types::TableHeaderScope::Row,
            TableHeaderScope::Column => pdf_writer::types::TableHeaderScope::Column,
            TableHeaderScope::Both => pdf_writer::types::TableHeaderScope::Both,
        }
    }
}

/// The positioning of the element with respect to the enclosing reference area
/// and other content.
/// When applied to an ILSE, any value except Inline shall cause the element to
/// be treated as a BLSE instead.
///
/// Default value: [`Placement::Inline`].
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum Placement {
    /// Stacked in the block-progression direction within an enclosing reference
    /// area or parent BLSE.
    Block,
    /// Packed in the inline-progression direction within an enclosing BLSE.
    #[default]
    Inline,
    /// Placed so that the before edge of the element’s allocation rectangle.
    /// (see “Content and Allocation Rectangles” in 14.8.5.4, “Layout Attributes”)
    /// coincides with that of the nearest enclosing reference area. The element
    /// may float, if necessary, to achieve the specified placement. The element
    /// shall be treated as a block occupying the full extent of the enclosing
    /// reference area in the inline direction. Other content shall be stacked
    /// so as to begin at the after edge of the element’s allocation rectangle.
    Before,
    /// Placed so that the start edge of the element’s allocation rectangle
    /// (see “Content and Allocation Rectangles” in 14.8.5.4, “Layout Attributes”)
    /// coincides with that of the nearest enclosing reference area. The element
    /// may float, if necessary, to achieve the specified placement. Other
    /// content that would intrude into the element’s allocation rectangle
    /// shall be laid out as a runaround.
    Start,
    /// Placed so that the end edge of the element’s allocation rectangle
    /// (see “Content and Allocation Rectangles” in 14.8.5.4, “Layout Attributes”)
    /// coincides with that of the nearest enclosing reference area. The element
    /// may float, if necessary, to achieve the specified placement. Other
    /// content that would intrude into the element’s allocation rectangle
    /// shall be laid out as a runaround.
    End,
}

impl Placement {
    pub(crate) fn to_pdf(self) -> pdf_writer::types::Placement {
        match self {
            Placement::Block => pdf_writer::types::Placement::Block,
            Placement::Inline => pdf_writer::types::Placement::Inline,
            Placement::Before => pdf_writer::types::Placement::Before,
            Placement::Start => pdf_writer::types::Placement::Start,
            Placement::End => pdf_writer::types::Placement::End,
        }
    }
}

/// The directions of layout progression for packing of ILSEs (inline progression)
/// and stacking of BLSEs (block progression).
/// The specified layout directions shall apply to the given structure element
/// and all of its descendants to any level of nesting.
///
/// Default value: [`WritingMode::LrTb`].
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum WritingMode {
    /// Inline progression from left to right; block progression from top to
    /// bottom. This is the typical writing mode for Western writing systems.
    #[default]
    LrTb,
    /// Inline progression from right to left; block progression from top to
    /// bottom. This is the typical writing mode for Arabic and Hebrew writing
    /// systems.
    RlTb,
    /// Inline progression from top to bottom; block progression from right to
    /// left. This is the typical writing mode for Chinese and Japanese writing
    /// systems.
    TbRl,
}

impl WritingMode {
    pub(crate) fn to_pdf(self) -> pdf_writer::types::WritingMode {
        match self {
            WritingMode::LrTb => pdf_writer::types::WritingMode::LtrTtb,
            WritingMode::RlTb => pdf_writer::types::WritingMode::RtlTtb,
            WritingMode::TbRl => pdf_writer::types::WritingMode::TtbRtl,
        }
    }
}

/// The bounding box of a tag that encloses its visible content.
/// If the content spans multiple pages, this should be omitted.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct BBox {
    /// The page index of the bounding box.
    pub page_idx: usize,
    /// The rectangle that encloses the content.
    pub rect: Rect,
}

impl BBox {
    /// Create a new bounding box.
    pub fn new(page_idx: usize, rect: Rect) -> Self {
        Self { page_idx, rect }
    }
}

/// An RGB color within the tag tree. The color space of this color is not
/// specified. Each component is in the range [0.0, 1.0].
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct NaiveRgbColor {
    /// The red component of the color.
    pub red: u8,
    /// The green component of the color.
    pub green: u8,
    /// The blue component of the color.
    pub blue: u8,
}

impl NaiveRgbColor {
    /// Create a new RGB color.
    pub fn new(red: u8, green: u8, blue: u8) -> Self {
        Self { red, green, blue }
    }

    /// Create a new RGB color from normalized floating point values.
    pub fn new_f32(red: f32, green: f32, blue: f32) -> Self {
        if !(0.0..=1.0).contains(&red)
            || !(0.0..=1.0).contains(&green)
            || !(0.0..=1.0).contains(&blue)
        {
            panic!("RGB color components must be in the range [0.0, 1.0]");
        }
        Self {
            red: (255.0 * red).round() as u8,
            green: (255.0 * green).round() as u8,
            blue: (255.0 * blue).round() as u8,
        }
    }

    /// Convert the color into an array of f32 components for PDF serialization.
    pub fn into_f32_array(self) -> [f32; 3] {
        let normalize = |n| n as f32 / 255.0;
        [self.red, self.green, self.blue].map(normalize)
    }
}

impl From<NaiveRgbColor> for crate::graphics::color::rgb::Color {
    fn from(color: NaiveRgbColor) -> Self {
        crate::graphics::color::rgb::Color::new(color.red, color.green, color.blue)
    }
}

impl From<NaiveRgbColor> for [f32; 3] {
    fn from(color: NaiveRgbColor) -> Self {
        color.into_f32_array()
    }
}

/// The border style of an element.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum BorderStyle {
    /// No border.
    None,
    /// Hidden border.
    Hidden,
    /// Solid border.
    Solid,
    /// Dashed border.
    Dashed,
    /// Dotted border.
    Dotted,
    /// Double border.
    Double,
    /// Groove border.
    Groove,
    /// Ridge border.
    Ridge,
    /// Inset border.
    Inset,
    /// Outset border.
    Outset,
}

impl BorderStyle {
    pub(super) fn to_pdf(self) -> pdf_writer::types::LayoutBorderStyle {
        match self {
            BorderStyle::None => pdf_writer::types::LayoutBorderStyle::None,
            BorderStyle::Hidden => pdf_writer::types::LayoutBorderStyle::Hidden,
            BorderStyle::Solid => pdf_writer::types::LayoutBorderStyle::Solid,
            BorderStyle::Dashed => pdf_writer::types::LayoutBorderStyle::Dashed,
            BorderStyle::Dotted => pdf_writer::types::LayoutBorderStyle::Dotted,
            BorderStyle::Double => pdf_writer::types::LayoutBorderStyle::Double,
            BorderStyle::Groove => pdf_writer::types::LayoutBorderStyle::Groove,
            BorderStyle::Ridge => pdf_writer::types::LayoutBorderStyle::Ridge,
            BorderStyle::Inset => pdf_writer::types::LayoutBorderStyle::Inset,
            BorderStyle::Outset => pdf_writer::types::LayoutBorderStyle::Outset,
        }
    }
}

/// The text alignment.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum TextAlign {
    /// At the start of the inline advance direction.
    Start,
    /// Centered.
    Center,
    /// At the end of the inline advance direction.
    End,
    /// Justified.
    Justify,
}

impl TextAlign {
    pub(super) fn to_pdf(self) -> pdf_writer::types::TextAlign {
        match self {
            TextAlign::Start => pdf_writer::types::TextAlign::Start,
            TextAlign::Center => pdf_writer::types::TextAlign::Center,
            TextAlign::End => pdf_writer::types::TextAlign::End,
            TextAlign::Justify => pdf_writer::types::TextAlign::Justify,
        }
    }
}

/// The block alignment.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum BlockAlign {
    /// At the start of the block advance direction.
    Begin,
    /// Centered.
    Middle,
    /// At the end of the block advance direction.
    After,
    /// Justified.
    Justify,
}

impl BlockAlign {
    pub(super) fn to_pdf(self) -> pdf_writer::types::BlockAlign {
        match self {
            BlockAlign::Begin => pdf_writer::types::BlockAlign::Before,
            BlockAlign::Middle => pdf_writer::types::BlockAlign::Middle,
            BlockAlign::After => pdf_writer::types::BlockAlign::After,
            BlockAlign::Justify => pdf_writer::types::BlockAlign::Justify,
        }
    }
}

/// The inline alignment.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum InlineAlign {
    /// At the start of the inline advance direction.
    Start,
    /// Centered.
    Center,
    /// At the end of the inline advance direction.
    End,
}

impl InlineAlign {
    pub(super) fn to_pdf(self) -> pdf_writer::types::InlineAlign {
        match self {
            InlineAlign::Start => pdf_writer::types::InlineAlign::Start,
            InlineAlign::Center => pdf_writer::types::InlineAlign::Center,
            InlineAlign::End => pdf_writer::types::InlineAlign::End,
        }
    }
}

/// The height of a line.
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum LineHeight {
    /// Adjust the line height automatically, taking `/BaselineShift` into
    /// account.
    Normal,
    /// Adjust the line height automatically.
    Auto,
    /// Set a fixed line height.
    Custom(f32),
}

impl LineHeight {
    pub(super) fn to_pdf(self) -> pdf_writer::types::LineHeight {
        match self {
            LineHeight::Auto => pdf_writer::types::LineHeight::Auto,
            LineHeight::Normal => pdf_writer::types::LineHeight::Normal,
            LineHeight::Custom(height) => pdf_writer::types::LineHeight::Custom(height),
        }
    }
}

/// The text decoration type (over- and underlines).
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum TextDecorationType {
    /// No decoration.
    None,
    /// Underlined.
    Underline,
    /// Line over the text.
    Overline,
    /// Strike the text.
    LineThrough,
}

impl TextDecorationType {
    pub(super) fn to_pdf(self) -> pdf_writer::types::TextDecorationType {
        match self {
            Self::None => pdf_writer::types::TextDecorationType::None,
            Self::Underline => pdf_writer::types::TextDecorationType::Underline,
            Self::Overline => pdf_writer::types::TextDecorationType::Overline,
            Self::LineThrough => pdf_writer::types::TextDecorationType::LineThrough,
        }
    }
}

/// The rotation of glyphs in vertical writing modes.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum GlyphOrientationVertical {
    /// Determine the rotation based on whether the text is full-width.
    Auto,
    /// No rotation.
    None,
    /// Rotate 90 degrees clockwise.
    Clockwise90,
    /// Rotate 90 degrees counter-clockwise.
    CounterClockwise90,
    /// Rotate 180 degrees clockwise.
    Clockwise180,
    /// Rotate 180 degrees counter-clockwise.
    CounterClockwise180,
    /// Rotate 270 degrees clockwise.
    Clockwise270,
}

impl GlyphOrientationVertical {
    /// Convert the rotation to a number. If the rotation is `Auto`, returns
    /// `None`.
    pub(super) fn to_pdf(self) -> pdf_writer::types::GlyphOrientationVertical {
        let angle = match self {
            GlyphOrientationVertical::Auto => {
                return pdf_writer::types::GlyphOrientationVertical::Auto
            }
            GlyphOrientationVertical::None => 0,
            GlyphOrientationVertical::Clockwise90 => 90,
            GlyphOrientationVertical::CounterClockwise90 => -90,
            GlyphOrientationVertical::Clockwise180 => 180,
            GlyphOrientationVertical::CounterClockwise180 => -180,
            GlyphOrientationVertical::Clockwise270 => 270,
        };
        pdf_writer::types::GlyphOrientationVertical::Angle(angle)
    }
}

/// An attribute value that can apply to all sides of the element, or have a specific value for each side.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Sides<T> {
    /// The start of the element on the block axis.
    pub before: T,
    /// The end of the element on the block axis.
    pub after: T,
    /// The start of the element on the inline axis.
    pub start: T,
    /// The end of the element on the inline axis.
    pub end: T,
}

impl<T> Sides<T> {
    /// Construct a new `Sides` value with specific values for each side.
    pub fn new(before: T, after: T, start: T, end: T) -> Self {
        Self {
            before,
            after,
            start,
            end,
        }
    }

    /// Construct a new `Sides` value with the same value for all sides.
    pub fn uniform(value: T) -> Self
    where
        T: Copy,
    {
        Sides {
            before: value,
            after: value,
            start: value,
            end: value,
        }
    }

    pub(crate) fn is_uniform(&self) -> bool
    where
        T: PartialEq,
    {
        self.before == self.after && self.before == self.start && self.before == self.end
    }

    /// Returns an array for all sides.
    pub(super) fn into_array(self) -> [T; 4] {
        [self.before, self.after, self.start, self.end]
    }

    /// Convert into [`pdf_writer::types::Sides`].
    pub(super) fn into_pdf(self) -> pdf_writer::types::Sides<T> {
        pdf_writer::types::Sides::from_array(self.into_array())
    }

    /// Convert into [`pdf_writer::types::Sides`] by each side value.
    pub(super) fn map_pdf<P>(self, to_pdf: impl Fn(T) -> P) -> pdf_writer::types::Sides<P> {
        pdf_writer::types::Sides::from_array(self.into_array().map(to_pdf))
    }
}

/// Widths related to columns, either for all columns or
/// with specific values for each.
#[derive(Debug, Clone, PartialEq)]
pub enum ColumnDimensions {
    /// The same value applies to all columns.
    All(f32),
    /// The value varies for each column or column gap.
    Specific(Vec<f32>),
}

impl ColumnDimensions {
    /// Construct a new `ColumnDimensions` with the same value for all columns.
    pub fn all(value: f32) -> Self {
        ColumnDimensions::All(value)
    }

    /// Construct a new `ColumnDimensions` with specific values for each column.
    pub fn specific(values: Vec<f32>) -> Self {
        ColumnDimensions::Specific(values)
    }
}