Skip to main content

razeri_plugin_contract/
large_object.rs

1// Copyright (C) 2026 Gabriel Shea
2// Licensed under either of the Apache License, Version 2.0 or the MIT
3// license, at your option.
4
5//! **A value an engine may hold as a large object**: how a load compares one,
6//! and the unit a length is counted in.
7//!
8//! Some engines hold a text column with no length — or bytes, or a document —
9//! as a large object (`CLOB`, `NCLOB`, `BLOB`), and such a value is not an
10//! ordinary value there: it cannot be grouped or compared directly, and its
11//! length may be counted in units other than characters. Razeri asks the
12//! dialect about each column with the type the load holds it in
13//! ([`HeldAs`]), through
14//! [`ExpressionRenderer::render_comparable`](crate::ExpressionRenderer::render_comparable)
15//! and [`ExpressionRenderer::text_length_unit`](crate::ExpressionRenderer::text_length_unit).
16
17/// **Where a load holds a column when it compares or measures it.**
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
19#[non_exhaustive]
20pub enum HeldAs {
21    /// As declared: the type the design gives the column, spelled through
22    /// [`SqlRenderer::render_data_type`](crate::SqlRenderer::render_data_type)
23    /// — a staging table, a dimension, a fact.
24    Declared,
25    /// Converted from staged text into the declared type, spelled through
26    /// [`SqlRenderer::render_cast_type`](crate::SqlRenderer::render_cast_type)
27    /// — a core table's load reads its rows this way.
28    Converted,
29}
30
31/// **The unit an engine's text length counts in.**
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
33#[non_exhaustive]
34pub enum TextLengthUnit {
35    /// One per character, whatever its code point: `Zoë` is three and an
36    /// emoji is one.
37    #[default]
38    Characters,
39    /// One per UTF-16 code unit: a character outside the basic plane, such as
40    /// an emoji, is two.
41    Utf16CodeUnits,
42}