use crate::bounded::NonEmpty;
use crate::identity::{OwnerFact, OwnerIdentity};
use crate::token::SpanHandle;
#[path = "type_guard.rs"]
mod guard;
pub use guard::{rendered_identifier, rendered_name};
pub const PATH_SEGMENT_LIMIT: usize = crate::token::RENDERED_PATH_SEGMENT_LIMIT;
pub const PROVIDER_LIMIT: usize = 64;
pub const DESCRIPTOR_MEANING_FACT: OwnerFact = OwnerFact {
home: "descriptor",
name: "a-descriptor-declaration-states-descriptor-meaning-alone",
};
pub const RENDERED_SPELLING_FACT: OwnerFact = OwnerFact {
home: "descriptor",
name: "a-rendered-spelling-is-one-rust-identifier",
};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Grammar {
pub attribute: &'static str,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Emitter {
pub namespace: &'static str,
pub producer: &'static str,
pub door: &'static str,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Name {
namespace: String,
stem: String,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SupportName(String);
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ModuleName(String);
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TypeName(String);
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FunctionName(String);
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DirectBinding {
segments: NonEmpty<String, PATH_SEGMENT_LIMIT>,
}
crate::roster! {
pub enum Seat {
PathSegment = "path-segment",
Role = "role",
Tag = "tag",
Row = "row",
SuiteGroup = "suite-group",
Aggregate = "aggregate",
Lens = "lens",
GeneratedItem = "generated-item",
AxisSize = "axis-size",
WorkFormulaByte = "work-formula-byte",
WorkObservation = "work-observation",
FactMapping = "fact-mapping",
Permission = "permission",
OperatorFamily = "operator-family",
Alternative = "alternative",
Provider = "provider",
}
}
#[must_use = "a declaration refusal names the seat the declaration did not fill"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum DeclarationError {
NamespaceEmpty,
StemEmpty,
NotAnIdentifier,
Absent {
seat: Seat,
},
Doubled {
seat: Seat,
},
Unbounded {
seat: Seat,
bound: u64,
observed: u64,
},
NotACurve {
observed: u64,
},
}
crate::roster! {
pub enum CaptureCause {
HelperDoubled = "helper-doubled",
BodyAbsent = "body-absent",
ClauseUnread = "clause-unread",
ClauseUndeclared = "clause-undeclared",
ClauseDoubled = "clause-doubled",
ClauseAbsent = "clause-absent",
ReferenceUnread = "reference-unread",
RosterUnread = "roster-unread",
GroupUnread = "group-unread",
RowUnread = "row-unread",
MappingUnread = "mapping-unread",
PermissionUnread = "permission-unread",
PathUnread = "path-unread",
ItemUnread = "item-unread",
OrderUnpressable = "order-unpressable",
ChoiceUnread = "choice-unread",
ChoiceDoubled = "choice-doubled",
NameUnshadowed = "name-unshadowed",
NothingChosen = "nothing-chosen",
PhraseUnread = "phrase-unread",
EndpointUnknown = "endpoint-unknown",
NumberBeyondSeat = "number-beyond-seat",
NameReserved = "name-reserved",
SeparatorDangling = "separator-dangling",
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CaptureIssue {
Grammar {
cause: CaptureCause,
},
Vocabulary {
refusal: DeclarationError,
},
}
#[must_use = "a helper refusal names the grammar, the cause, and the token it was established at"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct HelperRefusal {
grammar: Grammar,
issue: CaptureIssue,
at: SpanHandle,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Provider {
pub identity: OwnerIdentity,
pub home: OwnerFact,
pub composes: &'static str,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CompositionIssue {
ProviderDoubled {
provider: OwnerIdentity,
},
Declaration {
refusal: DeclarationError,
},
}
#[must_use = "a composition refusal carries the issues its declaration pass established"]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CompositionError {
first: CompositionIssue,
further: Vec<CompositionIssue>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Composition {
providers: NonEmpty<Provider, PROVIDER_LIMIT>,
}