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 = crate::token::RENDERED_PATH_SEGMENT_LIMIT;
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}
24/// Whether one support address must receive the declaring crate's path in order to reach its hidden carrier and generated cargo.
25#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
26pub(crate) enum DeclaringBinding {
27    /// The carrier and its cargo do not need the declaring crate's path.
28    Absent,
29    /// The consumption target must state the declaring crate's path.
30    Required,
31}
32crate::roster! {
33    /// The coupled gate-seat form.
34    pub enum DeliveryForm {
35        /// Trial table and deferred cargo.
36        Trials = "trials",
37        /// Benchmark table and reporter cargo.
38        Benches = "benches",
39    }
40}
41/// A support-declaration refusal.
42#[must_use = "a declaration refusal names the exact seat the declaration did not fill"]
43#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
44pub enum DeclarationError {
45    /// A name has no owner.
46    EmptyNamespace,
47    /// A name has no spelling.
48    EmptyStem,
49    /// A spelling is not one Rust identifier.
50    SpellingNotAnIdentifier,
51    /// A path has no segment after its root.
52    PathSegmentsAbsent,
53    /// A path exceeds its segment bound.
54    PathSegmentsUnbounded,
55}
56/// An owner namespace and spelling.
57#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
58pub struct WallName {
59    namespace: String,
60    stem: String,
61}
62/// A rendered path rooted at a declared crate facing.
63#[derive(Debug, Clone, PartialEq, Eq, Hash)]
64pub struct BoundPath {
65    facing: CrateFacing,
66    segments: NonEmpty<String, PATH_SEGMENT_LIMIT>,
67}
68/// The public alias a consumer invokes.
69#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
70pub struct SupportName(String);
71/// The rendered-identifier admission roads.
72pub use guard::{rendered_identifier, rendered_name};