Skip to main content

TypeSystem

Struct TypeSystem 

Source
pub struct TypeSystem(/* private fields */);
Expand description

Type system represents a set of strict types assembled from multiple libraries. It is designed to provide all necessary type information to analyze a type with all types it depends onto.

§Type guarantees

  • Total number of types do not exceed 2^24-1;
  • Strict-serialized size is less than 2^24 bytes;
  • A type with the same semantic id can’t appear in more than 256 libraries;
  • Type system is complete (i.e. no type references a type which is not a part of the system).

Implementations§

Source§

impl TypeSystem

Source

pub fn new() -> TypeSystem

Source

pub fn count_types(&self) -> u24

Source

pub fn get(&self, sem_id: SemId) -> Option<&Ty<SemId>>

Source

pub fn extend(&mut self, other: TypeSystem) -> Result<(), Error>

Source

pub fn extract( &self, ids: impl IntoIterator<Item = SemId>, ) -> Result<TypeSystem, UnknownType>

Source§

impl TypeSystem

Source

pub fn id(&self) -> TypeSysId

Source§

impl TypeSystem

Source

pub fn find(&self, sem_id: SemId) -> Option<&Ty<SemId>>

Source

pub fn typify(&self, val: StrictVal, sem_id: SemId) -> Result<TypedVal, Error>

Source§

impl TypeSystem

Source

pub fn strict_deserialize_type( &self, sem_id: SemId, data: &[u8], ) -> Result<TypedVal, Error>

Source

pub fn strict_read_type( &self, sem_id: SemId, d: &mut impl ReadRaw, ) -> Result<TypedVal, Error>

Source§

impl TypeSystem

Source

pub fn strict_serialize_value<const MAX_LEN: usize>( &self, typed: &TypedVal, ) -> Result<Confined<Vec<u8>, 0, MAX_LEN>, SerializeError>

Source

pub fn strict_serialize_type<const MAX_LEN: usize>( &self, typed: &TypedVal, ) -> Result<SerializedType<MAX_LEN>, SerializeError>

👎Deprecated since 2.7.2:

use strict_serialize_value instead

Source

pub fn strict_write_value( &self, typed: &TypedVal, writer: &mut impl Write, ) -> Result<(), Error>

Source

pub fn strict_write_type( &self, typed: &TypedVal, writer: &mut impl Write, ) -> Result<(), Error>

👎Deprecated since 2.7.2:

use strict_write_value instead

Methods from Deref<Target = Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>>§

Source

pub fn as_inner(&self) -> &C

👎Deprecated since 4.7.0:

use as_unconfined method

Returns inner collection type

Source

pub fn as_unconfined(&self) -> &C

Returns reference to the inner collection type.

Source

pub fn to_inner(&self) -> C
where C: Clone,

👎Deprecated since 4.7.0:

use to_unconfined method

Clones inner collection type and returns it

Source

pub fn to_unconfined(&self) -> C
where C: Clone,

Clones inner collection and returns an unconfined version of it.

Source

pub fn len_u8(&self) -> u8

Returns number of elements in the confined collection as u8. The confinement guarantees that the collection length can’t exceed u8::MAX.

Source

pub fn len_u16(&self) -> u16

Returns number of elements in the confined collection as u16. The confinement guarantees that the collection length can’t exceed u16::MAX.

Source

pub fn len_u24(&self) -> u24

Returns number of elements in the confined collection as u24. The confinement guarantees that the collection length can’t exceed u24::MAX.

Source

pub fn len_u32(&self) -> u32

Returns number of elements in the confined collection as u32. The confinement guarantees that the collection length can’t exceed u32::MAX.

Trait Implementations§

Source§

impl AsRef<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem

Source§

fn as_ref( &self, ) -> &Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem

Source§

fn borrow( &self, ) -> &Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>

Immutably borrows from an owned value. Read more
Source§

impl Clone for TypeSystem

Source§

fn clone(&self) -> TypeSystem

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 TypeSystem

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for TypeSystem

Source§

fn default() -> TypeSystem

Returns the “default value” for a type. Read more
Source§

impl DefaultBasedStrictDumb for TypeSystem

Source§

impl Deref for TypeSystem

Source§

type Target = Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<TypeSystem as Deref>::Target

Dereferences the value.
Source§

impl<'de> Deserialize<'de> for TypeSystem

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<TypeSystem, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for TypeSystem

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for TypeSystem

Source§

impl From<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem

Source§

fn from( v: Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>, ) -> TypeSystem

Converts to this type from the input type.
Source§

impl From<TypeSystem> for Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>

Source§

fn from( wrapped: TypeSystem, ) -> Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>

Converts to this type from the input type.
Source§

impl Index<SemId> for TypeSystem

Source§

type Output = Ty<SemId>

The returned type after indexing.
Source§

fn index(&self, index: SemId) -> &<TypeSystem as Index<SemId>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl PartialEq for TypeSystem

Source§

fn eq(&self, other: &TypeSystem) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl SemCommit for TypeSystem

Source§

fn sem_commit(&self, hasher: &mut impl CommitConsume)

Source§

impl Serialize for TypeSystem

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StrictArmor for TypeSystem

Available on crate feature armor only.
Source§

const PLATE_TITLE: &'static str = "STRICT TYPE SYSTEM"

Source§

type Id = TypeSysId

Source§

fn armor_id(&self) -> <TypeSystem as StrictArmor>::Id

Source§

fn checksum_armor(&self) -> bool

Source§

fn armor_headers(&self) -> Vec<ArmorHeader>

Source§

fn parse_armor_headers( &mut self, _headers: Vec<ArmorHeader>, ) -> Result<(), StrictArmorError>

Source§

impl StrictDecode for TypeSystem

Source§

impl StrictDeserialize for TypeSystem

Source§

fn from_strict_serialized<const MAX: usize>( ast_data: Confined<Vec<u8>, 0, MAX>, ) -> Result<Self, DeserializeError>

Source§

fn strict_deserialize_from_file<const MAX: usize>( path: impl AsRef<Path>, ) -> Result<Self, DeserializeError>

Source§

impl StrictEncode for TypeSystem

Source§

fn strict_encode<W>(&self, writer: W) -> Result<W, Error>
where W: TypedWrite,

Source§

fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>

Source§

impl StrictProduct for TypeSystem

Source§

impl StrictSerialize for TypeSystem

Source§

fn strict_serialized_len<const MAX: usize>(&self) -> Result<usize, Error>

Source§

fn to_strict_serialized<const MAX: usize>( &self, ) -> Result<Confined<Vec<u8>, 0, MAX>, SerializeError>

Source§

fn strict_serialize_to_file<const MAX: usize>( &self, path: impl AsRef<Path>, ) -> Result<(), SerializeError>

Source§

impl StrictTuple for TypeSystem

Source§

impl StrictType for TypeSystem

Source§

const STRICT_LIB_NAME: &'static str = STRICT_TYPES_LIB

Source§

fn strict_name() -> Option<TypeName>

Source§

impl StructuralPartialEq for TypeSystem

Source§

impl Wrapper for TypeSystem

Source§

type Inner = Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>

Inner type wrapped by the current newtype
Source§

fn from_inner(inner: <TypeSystem as Wrapper>::Inner) -> TypeSystem

Instantiates wrapper type with the inner data
Source§

fn as_inner(&self) -> &<TypeSystem as Wrapper>::Inner

Returns reference to the inner representation for the wrapper type
Source§

fn into_inner(self) -> <TypeSystem as Wrapper>::Inner

Unwraps the wrapper returning the inner type
Source§

fn to_inner(&self) -> Self::Inner
where Self::Inner: Clone,

Clones inner data of the wrapped type and return them
Source§

fn copy(&self) -> Self
where Self: Sized, Self::Inner: Copy,

Copies the wrapped type

Auto Trait Implementations§

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> AsciiArmor for T
where T: StrictArmor,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StrictDumb for T

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> VerifyEq for T
where T: Eq,

Source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.
Source§

impl<T> VerifyEq for T
where T: Eq,

Source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.