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
//! # xportrs
//!
//! Pure Rust SAS XPORT (XPT) reader and writer for CDISC clinical trial data submissions.
//!
//! `xportrs` provides a safe, DataFrame-agnostic implementation of XPT v5 I/O
//! with built-in regulatory compliance validation for FDA, PMDA, and NMPA submissions.
//!
//! ## Quick Start
//!
//! ### Reading an XPT file
//!
//! ```no_run
//! use xportrs::Xpt;
//!
//! // Read the first dataset from a file
//! let dataset = Xpt::read("ae.xpt")?;
//! println!("Domain: {}", dataset.domain_code());
//! println!("Rows: {}", dataset.nrows());
//!
//! // Read a specific member from a multi-dataset file
//! let dm = Xpt::reader("study.xpt")?.read_member("DM")?;
//! # Ok::<(), xportrs::Error>(())
//! ```
//!
//! ### Writing an XPT file
//!
//! ```no_run
//! use xportrs::{Xpt, Agency, Dataset, Column, ColumnData};
//!
//! let dataset = Dataset::new(
//! "AE", // Domain code (accepts &str, String, or DomainCode)
//! vec![
//! Column::new("USUBJID", ColumnData::String(vec![
//! Some("01-001".into()),
//! Some("01-002".into()),
//! ])),
//! Column::new("AESEQ", ColumnData::I64(vec![Some(1), Some(1)])),
//! ],
//! )?;
//!
//! // Write with structural validation only
//! Xpt::writer(dataset.clone()).finalize()?.write_path("ae.xpt")?;
//!
//! // Write with FDA agency compliance validation
//! let mut builder = Xpt::writer(dataset);
//! builder.agency(Agency::FDA);
//! builder.finalize()?.write_path("ae_fda.xpt")?;
//! # Ok::<(), xportrs::Error>(())
//! ```
//!
//! ## Entry Points
//!
//! The [`Xpt`] struct provides all main functionality:
//!
//! - [`Xpt::read`] - Read a file in one line
//! - [`Xpt::reader`] - Read with options (member selection, etc.)
//! - [`Xpt::writer`] - Build a validated write plan
//! - [`Xpt::inspect`] - Examine file metadata without loading data
//!
//! ## Data Types
//!
//! - [`Dataset`] - Tabular data container with domain code and columns
//! - [`Column`] - Single variable with name and data
//! - [`ColumnData`] - Type-safe column values (numeric, character, date/time)
//! - [`DomainCode`] - Type-safe domain identifier (e.g., "AE", "DM", "LB")
//! - [`Label`] - Type-safe label string for datasets and variables
//!
//! ## Validation & Compliance
//!
//! - [`Agency`] - Regulatory agencies ([`Agency::FDA`], [`Agency::PMDA`], [`Agency::NMPA`])
//! - [`Issue`] - Validation problems with severity and context
//! - [`Severity`] - [`Severity::Error`] (blocking) or [`Severity::Warning`] (informational)
//!
//! When an agency is specified, the following rules are enforced:
//!
//! - ASCII-only names, labels, and character values
//! - Dataset names: max 8 bytes, uppercase alphanumeric
//! - Variable names: max 8 bytes, uppercase alphanumeric with underscores
//! - Labels: max 40 bytes
//! - Character values: max 200 bytes
//! - Automatic file splitting for files exceeding 5GB
//!
//! ## Feature Flags
//!
//! | Feature | Description |
//! |-----------|---------------------------------------------------|
//! | `serde` | Serialization/deserialization support |
//! | `tracing` | Structured logging with the `tracing` crate |
//! | `polars` | Polars `DataFrame` integration |
//! | `full` | All optional features |
//!
//! ## CDISC Terminology
//!
//! This crate uses CDISC SDTM vocabulary:
//!
//! - **Domain dataset**: A table identified by a [`DomainCode`] (e.g., "AE", "DM", "LB")
//! - **Observation**: One row/record in the [`Dataset`]
//! - **Variable**: One [`Column`]; may have a [`VariableRole`]
// Core modules
// Optional integrations
// Main entry point - the unified API
pub use ;
// Agency for compliance validation
pub use Agency;
// Configuration types users may need
pub use ;
// Dataset types - needed to construct data
pub use ;
// Error types
pub use ;
// Metadata types - for advanced usage
pub use XptVarType;
// Validation types
pub use ;
// Write plan types
pub use ;
// XPT version enum
pub use XptVersion;
// XPT file info (for Xpt::inspect)
pub use XptInfo;
/// Temporal conversion utilities.
///
/// These functions convert between Rust chrono types and SAS date/time values.