Skip to main content

fhir_mysql_store/
lib.rs

1//! fhir-mysql-store: the MySQL layer. Applies generated DDL, writes
2//! shredded resources transactionally with history, and reads rows back for
3//! reconstruction.
4//!
5//! Values bind through `mysql_async` as text for the same reason as every other
6//! port: `M3.6`/`R4.2` require decimal scale and partial dates to survive
7//! round-trip, so nothing numeric may parse them on the way through.
8//!
9//! # Trademarks
10//!
11//! HL7®, and FHIR® are the registered trademarks of Health Level Seven
12//! International and their use of these trademarks does not constitute an
13//! endorsement by HL7.
14// Nothing here has any business dereferencing a raw pointer: this code
15// parses and reshapes untrusted clinical data, and memory safety is the
16// property that keeps a malformed resource from becoming a vulnerability.
17#![forbid(unsafe_code)]
18
19/// The tamper-evident audit chain, shared by every port (`M3.16`).
20pub use fhir_store::chain;
21pub mod mysql;
22pub mod mysql_search;
23pub mod ssl;
24
25use thiserror::Error;
26
27#[derive(Debug, Error)]
28pub enum StoreError {
29    #[error("pool: {0}")]
30    Pool(String),
31    /// A database failure, as the engine reported it.
32    #[error("mysql: {0}")]
33    Db(String),
34    #[error("shred: {0}")]
35    Shred(#[from] fhir_mysql_map::ShredError),
36    /// Optimistic-concurrency failure: the caller's expected version does
37    /// not match the stored one (HTTP 412 at the API layer).
38    #[error("version conflict: expected {expected}, found {found}")]
39    Conflict { expected: i64, found: i64 },
40    /// A client-safe rejection: the request asked for something this server
41    /// does not do, described in terms of the request itself (a parameter
42    /// name, a modifier, a sort key). Safe to return verbatim — it names
43    /// what the caller sent, never what is stored (spec A7.11).
44    #[error("{0}")]
45    Unsupported(String),
46    /// An internal failure. The text is diagnostics for the operator and may
47    /// mention schema or values, so it belongs in the log behind an incident
48    /// id, never in a response body.
49    #[error("{0}")]
50    Other(String),
51}
52
53/// The engine-agnostic value types, shared by every port.
54///
55/// Re-exported rather than redefined: these were duplicated in all six ports
56/// until **F-45**, and a re-export means a caller written against one port
57/// compiles against another without a conversion.
58pub use fhir_store::{
59    AccessRecord, Audit, ChainBreak, CondCreate, CondDelete, Got, HistEntry, PurgeReport,
60    PutOutcome, ResourceStatus, SearchOutcome, TxOp, TxOutcome, UpgradeOpts, UpgradeReport,
61};