pub struct Catalog { /* private fields */ }Expand description
The declarations a set of types names, with the std enums whose values the encoding builds itself.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn new(
decls: Vec<Decl>,
option: Arc<EnumShape>,
json: Option<Arc<EnumShape>>,
) -> Result<Self, DecodeError>
pub fn new( decls: Vec<Decl>, option: Arc<EnumShape>, json: Option<Arc<EnumShape>>, ) -> Result<Self, DecodeError>
Returns the catalog of decls, where the nth is DeclId n,
with std’s Option (None, Some(T)) and, when the program has it,
json.Value.
§Errors
When either shape lacks a constructor std declares, or when a
declaration’s recursion is not regular (types.md, Recursive
types), which every judgment of the catalog’s types relies on to end.
Sourcepub fn std(decls: Vec<Decl>) -> Result<Catalog, DecodeError>
pub fn std(decls: Vec<Decl>) -> Result<Catalog, DecodeError>
The catalog of decls, with the Option and json.Value shapes
of the bundled std (std_enum), whose tests hold them to the
constructors the encoding builds.
§Errors
When a declaration’s recursion is not regular, as Catalog::new.
Sourcepub fn decls(&self) -> impl ExactSizeIterator<Item = (DeclId, &Decl)>
pub fn decls(&self) -> impl ExactSizeIterator<Item = (DeclId, &Decl)>
Every declaration, by id.
§Panics
When the catalog holds more declarations than a 32-bit id numbers.
Sourcepub fn same(&self, ty: &Type, other: &Catalog, other_ty: &Type) -> bool
pub fn same(&self, ty: &Type, other: &Catalog, other_ty: &Type) -> bool
Whether ty, named in this catalog, is the type other_ty is in
other: the same former over the same parts, each declared type
known by its identity and ordinal, so that a newtype is never its
base (types.md, Erasure).
Sourcepub fn matches(
&self,
ty: &Type,
other: &Catalog,
other_ty: &Type,
params: &mut impl Params,
) -> bool
pub fn matches( &self, ty: &Type, other: &Catalog, other_ty: &Type, params: &mut impl Params, ) -> bool
Whether ty, named in this catalog, is the type other_ty is in
other, as Catalog::same compares them, except that each type
parameter of ty matches as params decides.
Sourcepub fn erase<'t>(&self, ty: &'t Type) -> Cow<'t, Type>
pub fn erase<'t>(&self, ty: &'t Type) -> Cow<'t, Type>
The erasure of ty: ty itself when it is no newtype, and
otherwise the erasure of its base at its arguments (types.md,
Erasure). Every rule that reads a position’s type reads this.
A cycle of newtypes, which the checker and a description’s
validation both refuse, erases to Type::NotData.
Sourcepub fn std_form(&self, ty: &Type) -> Option<StdForm>
pub fn std_form(&self, ty: &Type) -> Option<StdForm>
The form a value of ty is held to: that of the std type with a
form (StdForm::of) that ty is, or erases through on the way
to its erasure, if any.
Sourcepub fn none(&self) -> Value
pub fn none(&self) -> Value
std’s None: the value of every type that erases to an Option
and is absent.
§Panics
Never: None is a case of std’s Option that carries nothing.