ecbdp_api/parameter/metadata.rs
1use std::fmt::Display;
2
3
4#[derive(Clone, Copy, Debug, Default)]
5/// Using the detail parameter, you can specify the desired amount of information to be returned.
6/// For example, it is possible to instruct the web service to return only basic information about the resource
7/// (i.e., its id, agency id, version and name. This is also known as a stub in SDMX).
8pub enum Detail {
9 #[default]
10 /// All available information for all artefacts will be returned. This is the default.
11 Full,
12 /// All artefacts will be returned as stubs
13 AllStubs,
14 /// The referenced artefacts will be returned as stubs
15 ReferenceStubs,
16}
17
18impl Display for Detail {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self {
21 Self::Full => write!(f, "full"),
22 Self::AllStubs => write!(f, "allstubs"),
23 Self::ReferenceStubs => write!(f, "referencestubs"),
24 }
25 }
26}
27
28
29#[derive(Clone, Copy, Debug, Default)]
30/// Using the references parameter, you can instruct the web service to return (or exclude)
31/// the artefacts that use or are referenced by the artefact matching the query.
32/// This includes, for example, the codelists and Concepts used by the DSD matching the query.
33/// You can also retrieve the artefacts that use the matching artefact, such as the Dataflows that use the DSD matching the query.
34pub enum References {
35 #[default]
36 /// No references will be returned. This is the default.
37 None,
38 /// The artefacts that use the artefact matching the query (for example, the Dataflows that use the DSD matching the query) will be returned
39 Parents,
40 /// The artefacts that use the artefact matching the query, as well as the artefacts referenced by these artefacts, will be returned
41 ParentsAndSiblings,
42 /// The artefacts referenced by the matching artefact (for example, the Concept schemes and codelists used in a DSD) will be returned
43 Children,
44 /// References of references, up to any level, will also be returned
45 Descendants,
46 /// The combination of `ParentsAndSiblings` and `Descendants`
47 All,
48}
49
50impl Display for References {
51 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52 match self {
53 Self::None => write!(f, "none"),
54 Self::Parents => write!(f, "parents"),
55 Self::ParentsAndSiblings => write!(f, "parentsandsiblings"),
56 Self::Children => write!(f, "children"),
57 Self::Descendants => write!(f, "descendants"),
58 Self::All => write!(f, "all"),
59 }
60 }
61}
62
63
64#[derive(Clone, Debug)]
65/// Parameter types for `metadata` queries.
66pub enum MetadataParameter {
67 /// Using the detail parameter, you can specify the desired amount of information to be returned.
68 /// For example, it is possible to instruct the web service to return only basic information about the resource
69 /// (i.e., its id, agency id, version and name. This is also known as a stub in SDMX).
70 Detail { detail: Detail, },
71 /// Using the references parameter, you can instruct the web service to return (or exclude)
72 /// the artefacts that use or are referenced by the artefact matching the query.
73 /// This includes, for example, the codelists and Concepts used by the DSD matching the query.
74 /// You can also retrieve the artefacts that use the matching artefact, such as the Dataflows that use the DSD matching the query.
75 References { references: References, },
76}
77
78impl Display for MetadataParameter {
79 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80 match self {
81 Self::Detail { detail } => write!(f, "detail={}", detail.to_string()),
82 Self::References { references } => write!(f, "references={}", references.to_string()),
83 }
84 }
85}