Skip to main content

macroonz_compiler/support/
types.rs

1//! Cross-cutting declaration and schema vocabulary.
2use crate::bounded::NonEmpty;
3#[path = "type_guard.rs"]
4mod guard;
5/// The maximum rendered path depth after its crate root.
6pub const PATH_SEGMENT_LIMIT: usize = 8;
7/// A generated-support schema identity.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub struct SchemaId([u8; 32]);
10/// The compiler's pinned generated-support schema expectation.
11pub const EXPECTED_SCHEMA_ID: SchemaId = SchemaId::pinned([
12    185, 251, 251, 45, 168, 146, 85, 42, 248, 177, 196, 48, 117, 229, 207, 5, 84, 120, 104, 25,
13    150, 41, 202, 2, 243, 73, 31, 148, 241, 22, 122, 34,
14]);
15crate::roster! {
16    /// The crate at which a rendered path is rooted.
17    pub enum CrateFacing {
18        /// The declaring crate.
19        Declaring = "declaring",
20        /// The harness crate.
21        Harness = "harness",
22    }
23}
24crate::roster! {
25    /// The coupled gate-seat form.
26    pub enum DeliveryForm {
27        /// Trial table and deferred cargo.
28        Trials = "trials",
29        /// Benchmark table and reporter cargo.
30        Benches = "benches",
31    }
32}
33/// A support-declaration refusal.
34#[must_use = "a declaration refusal names the exact seat the declaration did not fill"]
35#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
36pub enum DeclarationError {
37    /// A name has no owner.
38    EmptyNamespace,
39    /// A name has no spelling.
40    EmptyStem,
41    /// A spelling is not one Rust identifier.
42    SpellingNotAnIdentifier,
43    /// A path has no segment after its root.
44    PathSegmentsAbsent,
45    /// A path exceeds its segment bound.
46    PathSegmentsUnbounded,
47}
48/// An owner namespace and spelling.
49#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
50pub struct WallName {
51    namespace: String,
52    stem: String,
53}
54/// A rendered path rooted at a declared crate facing.
55#[derive(Debug, Clone, PartialEq, Eq, Hash)]
56pub struct BoundPath {
57    facing: CrateFacing,
58    segments: NonEmpty<String, PATH_SEGMENT_LIMIT>,
59}
60/// The public alias a consumer invokes.
61#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
62pub struct SupportName(String);
63/// The rendered-identifier admission roads.
64pub use guard::{rendered_identifier, rendered_name};