sdmx_json/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! A Rust implementation of SDMX-JSON (Statistical Data and Metadata eXchange)
4//! using Serde.
5//!
6//! All JSON files are implemented with a top-level type, e.g
7//! [`DataMesssage`][crate::data::DataMessage],
8//! [`MetadataMessage`][crate::metadata::MetadataMessage],
9//! and [`StructureMessage`][crate::structure::StructureMessage]. Likewise,
10//! all of these types can be deserialized from the following types:
11//!
12//! - a [`&str`] through implementing the [`FromStr`][std::str::FromStr] trait,
13//! which internally calls [`serde_json::from_str()`][serde_json::from_str]
14//! - a [`&[u8]`][slice] through implementing `TryFrom<&u8>`,
15//! which internally calls [`serde_json::from_slice()`][serde_json::from_slice]
16//! - a [`Value`][serde_json::Value] through implementing `TryFrom<Value>`,
17//! which internally calls [`serde_json::from_value()`][serde_json::from_value]
18//! - any type that implements [`Read`](`std::io::Read`) by directly calling
19//! [`serde_json::from_reader()`][serde_json::from_reader]
20
21#[macro_use]
22mod macros;
23
24/// SDMX-JSON Data Message format, 2.0.0 (aligned with SDMX 3.0.0)
25///
26/// This module implements [SDMX-JSON Data Message 2.0.0][data].
27/// The Data Message format allows for exchanging contextual statistics
28/// data via the JSON file format.
29///
30/// JSON files in this format are implemented in the top-level root type,
31/// [`DataMessage`][crate::data::DataMessage].
32/// They can be deserialized from a [`&str`], a [`&[u8]`][slice],
33/// and a [`Value`][serde_json::Value].
34///
35/// [data]: <https://github.com/sdmx-twg/sdmx-json/tree/master/data-message>
36pub mod data;
37
38/// SDMX-JSON Metadata Message format, 2.0.0 (aligned with SDMX 3.0.0)
39///
40/// This module implements [SDMX-JSON Metadata Message 2.0.0][metadata].
41/// The Metadata Message format includes information that describes
42/// the statistical data itself.
43///
44/// JSON files in this format are implemented in the top-level root type,
45/// [`MetadataMessage`][crate::metadata::MetadataMessage].
46/// They can be deserialized from a [`&str`], a [`&[u8]`][slice],
47/// and a [`Value`][serde_json::Value].
48///
49/// [metadata]: <https://github.com/sdmx-twg/sdmx-json/tree/master/metadata-message>
50pub mod metadata;
51
52/// Common foundational types shared between the message formats
53pub mod primitives;
54
55/// SDMX-JSON Structure Message format, 2.0.0 (aligned with SDMX 3.0.0)
56///
57/// This module implements [SDMX-JSON Structure Message 2.0.0][structure].
58/// The Structure Message format is used for describing objects in
59/// RESTful API services to make data more easily discoverable
60/// and consumable.
61///
62/// JSON files in this format are implemented in the top-level root type,
63/// [`StructureMessage`][crate::structure::StructureMessage].
64/// They can be deserialized from a [`&str`], a [`&[u8]`][slice],
65/// and a [`Value`][serde_json::Value].
66///
67/// [structure]: https://github.com/sdmx-twg/sdmx-json/tree/master/structure-message
68pub mod structure;