Skip to content

Commit 6709cbc

Browse files
committed
revert some moves
1 parent d429940 commit 6709cbc

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

hugr-core/src/envelope.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,30 @@ use itertools::Itertools as _;
6363

6464
use crate::import::ImportError;
6565

66-
pub use description::{GENERATOR_KEY, USED_EXTENSIONS_KEY};
66+
// TODO centralise all core metadata keys in one place.
67+
68+
/// Key used to store the name of the generator that produced the envelope.
69+
pub const GENERATOR_KEY: &str = "core.generator";
70+
/// Key used to store the list of used extensions in the metadata of a HUGR.
71+
pub const USED_EXTENSIONS_KEY: &str = "core.used_extensions";
72+
73+
/// Get the name of the generator from the metadata of the HUGR modules.
74+
///
75+
/// If multiple modules have different generators, a comma-separated list is returned in
76+
/// module order.
77+
/// If no generator is found, `None` is returned.
78+
pub fn get_generator<H: HugrView>(modules: &[H]) -> Option<String> {
79+
let generators: Vec<String> = modules
80+
.iter()
81+
.filter_map(|hugr| hugr.get_metadata(hugr.module_root(), GENERATOR_KEY))
82+
.map(format_generator)
83+
.collect();
84+
if generators.is_empty() {
85+
return None;
86+
}
87+
88+
Some(generators.join(", "))
89+
}
6790

6891
/// Format a generator value from the metadata.
6992
pub fn format_generator(json_val: &serde_json::Value) -> String {
@@ -96,24 +119,6 @@ fn gen_str(generator: Option<&String>) -> String {
96119
}
97120
}
98121

99-
/// Get the name of the generator from the metadata of the HUGR modules.
100-
///
101-
/// If multiple modules have different generators, a comma-separated list is returned in
102-
/// module order.
103-
/// If no generator is found, `None` is returned.
104-
pub fn get_generator<H: HugrView>(modules: &[H]) -> Option<String> {
105-
let generators: Vec<String> = modules
106-
.iter()
107-
.filter_map(|hugr| hugr.get_metadata(hugr.module_root(), GENERATOR_KEY))
108-
.map(format_generator)
109-
.collect();
110-
if generators.is_empty() {
111-
return None;
112-
}
113-
114-
Some(generators.join(", "))
115-
}
116-
117122
/// Wrap an error with a generator string.
118123
#[derive(Error, Debug)]
119124
#[deprecated(since = "0.24.1", note = "Use PackageDesc instead")]

hugr-core/src/envelope/description.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use semver::Version;
33

44
use crate::{
55
HugrView, Node,
6-
envelope::EnvelopeHeader,
6+
envelope::{EnvelopeHeader, USED_EXTENSIONS_KEY},
77
ops::{DataflowOpTrait, OpType},
88
};
99

@@ -343,13 +343,6 @@ impl<H: HugrView<Node = Node>> From<&H> for ModuleDesc {
343343
}
344344
}
345345

346-
// TODO centralise all core metadata keys in one place.
347-
348-
/// Key used to store the name of the generator that produced the envelope.
349-
pub const GENERATOR_KEY: &str = "core.generator";
350-
/// Key used to store the list of used extensions in the metadata of a HUGR.
351-
pub const USED_EXTENSIONS_KEY: &str = "core.used_extensions";
352-
353346
#[cfg(test)]
354347
mod test {
355348
use super::*;

0 commit comments

Comments
 (0)