Skip to main content

Catalog

Struct Catalog 

Source
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

Source

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.

Source

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.

Source

pub fn decl(&self, id: DeclId) -> &Decl

The declaration id names.

§Panics

When id is not one of this catalog’s.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn some(&self, value: Value) -> Value

std’s Some(value).

§Panics

Never: Some is a case of std’s Option that carries one value.

Source

pub fn name(&self, ty: &Type) -> String

How ty is written in a schema’s $defs key and in messages: built-in types by name, declarations by identity, with arguments.

Trait Implementations§

Source§

impl Clone for Catalog

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Catalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Catalog

§

impl Forget for Catalog

§

impl Move for Catalog

§

impl RefUnwindSafe for Catalog

§

impl Send for Catalog
where RawVecInner: Send, Arc<RecordShape>: Send, BoxRaw<Type>: Send, Arc<EnumShape>: Send, Mutex<HashMap<(Type, Settings), Option<String>>>: Send, RawTable<(Box<str>, usize)>: Send, BoxRaw<[usize]>: Send, BoxRaw<[Option<OptionCtor>]>: Send, BoxRaw<[Option<JsonValueCtor>]>: Send,

§

impl Sync for Catalog
where RawVecInner: Sync, Arc<RecordShape>: Sync, BoxRaw<Type>: Sync, Arc<EnumShape>: Sync, Mutex<HashMap<(Type, Settings), Option<String>>>: Sync, RawTable<(Box<str>, usize)>: Sync, BoxRaw<[usize]>: Sync, BoxRaw<[Option<OptionCtor>]>: Sync, BoxRaw<[Option<JsonValueCtor>]>: Sync,

§

impl Unpin for Catalog

§

impl UnsafeUnpin for Catalog

§

impl UnwindSafe for Catalog

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.