Skip to main content

ferroui_pretext_contracts/
lib.rs

1//! Backend contracts for reusable text preparation and glyph-run output.
2//!
3//! Layout cursors count graphemes; glyph clusters count UTF-16 code units.
4//! Implementations use ordinary Rust ownership instead of explicit disposal.
5
6#![forbid(unsafe_code)]
7
8mod pretext_font_descriptor;
9mod text_measurement_contracts;
10mod text_shaping_contracts;
11
12pub use pretext_font_descriptor::*;
13pub use text_measurement_contracts::*;
14pub use text_shaping_contracts::*;
15
16/// A recoverable backend or input error.
17#[derive(Clone, Debug, PartialEq, Eq)]
18pub enum PretextError {
19    /// No glyph shaping backend was configured.
20    NoShapingBackend,
21    /// A backend could not create or execute a text service.
22    Backend(String),
23    /// Input is outside the supported contract.
24    InvalidInput(String),
25}
26
27impl std::fmt::Display for PretextError {
28    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29        match self {
30            Self::NoShapingBackend => f.write_str("no text shaping backend is configured"),
31            Self::Backend(message) | Self::InvalidInput(message) => f.write_str(message),
32        }
33    }
34}
35
36impl std::error::Error for PretextError {}