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
impl TypeSystem
pub fn new() -> TypeSystem
pub fn count_types(&self) -> u24
pub fn get(&self, sem_id: SemId) -> Option<&Ty<SemId>>
pub fn extend(&mut self, other: TypeSystem) -> Result<(), Error>
pub fn extract( &self, ids: impl IntoIterator<Item = SemId>, ) -> Result<TypeSystem, UnknownType>
Source§impl TypeSystem
impl TypeSystem
Source§impl TypeSystem
impl TypeSystem
Source§impl TypeSystem
impl TypeSystem
pub fn strict_serialize_value<const MAX_LEN: usize>( &self, typed: &TypedVal, ) -> Result<Confined<Vec<u8>, 0, MAX_LEN>, SerializeError>
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
pub fn strict_write_value( &self, typed: &TypedVal, writer: &mut impl Write, ) -> Result<(), Error>
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}>>§
Sourcepub fn as_inner(&self) -> &C
👎Deprecated since 4.7.0: use as_unconfined method
pub fn as_inner(&self) -> &C
Returns inner collection type
Sourcepub fn as_unconfined(&self) -> &C
pub fn as_unconfined(&self) -> &C
Returns reference to the inner collection type.
Sourcepub fn to_inner(&self) -> Cwhere
C: Clone,
👎Deprecated since 4.7.0: use to_unconfined method
pub fn to_inner(&self) -> Cwhere
C: Clone,
Clones inner collection type and returns it
Sourcepub fn to_unconfined(&self) -> Cwhere
C: Clone,
pub fn to_unconfined(&self) -> Cwhere
C: Clone,
Clones inner collection and returns an unconfined version of it.
Sourcepub fn len_u8(&self) -> u8
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.
Sourcepub fn len_u16(&self) -> u16
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.
Trait Implementations§
Source§impl AsRef<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem
impl AsRef<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem
Source§impl Borrow<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem
impl Borrow<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem
Source§impl Clone for TypeSystem
impl Clone for TypeSystem
Source§fn clone(&self) -> TypeSystem
fn clone(&self) -> TypeSystem
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TypeSystem
impl Debug for TypeSystem
Source§impl Default for TypeSystem
impl Default for TypeSystem
Source§fn default() -> TypeSystem
fn default() -> TypeSystem
Returns the “default value” for a type. Read more
Source§impl Deref for TypeSystem
impl Deref for TypeSystem
Source§impl<'de> Deserialize<'de> for TypeSystem
impl<'de> Deserialize<'de> for TypeSystem
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TypeSystem, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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
impl Display for TypeSystem
Source§impl From<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem
impl From<Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>> for TypeSystem
Source§impl From<TypeSystem> for Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>
impl From<TypeSystem> for Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>
Source§impl Index<SemId> for TypeSystem
impl Index<SemId> for TypeSystem
Source§impl PartialEq for TypeSystem
impl PartialEq for TypeSystem
Source§impl SemCommit for TypeSystem
impl SemCommit for TypeSystem
fn sem_commit(&self, hasher: &mut impl CommitConsume)
Source§impl Serialize for TypeSystem
impl Serialize for TypeSystem
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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.
impl StrictArmor for TypeSystem
Available on crate feature
armor only.const PLATE_TITLE: &'static str = "STRICT TYPE SYSTEM"
type Id = TypeSysId
fn armor_id(&self) -> <TypeSystem as StrictArmor>::Id
fn checksum_armor(&self) -> bool
fn armor_headers(&self) -> Vec<ArmorHeader>
fn parse_armor_headers( &mut self, _headers: Vec<ArmorHeader>, ) -> Result<(), StrictArmorError>
Source§impl StrictDecode for TypeSystem
impl StrictDecode for TypeSystem
fn strict_decode(reader: &mut impl TypedRead) -> Result<TypeSystem, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDeserialize for TypeSystem
impl StrictDeserialize for TypeSystem
fn from_strict_serialized<const MAX: usize>( ast_data: Confined<Vec<u8>, 0, MAX>, ) -> Result<Self, DeserializeError>
fn strict_deserialize_from_file<const MAX: usize>( path: impl AsRef<Path>, ) -> Result<Self, DeserializeError>
Source§impl StrictEncode for TypeSystem
impl StrictEncode for TypeSystem
fn strict_encode<W>(&self, writer: W) -> Result<W, Error>where
W: TypedWrite,
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictSerialize for TypeSystem
impl StrictSerialize for TypeSystem
fn strict_serialized_len<const MAX: usize>(&self) -> Result<usize, Error>
fn to_strict_serialized<const MAX: usize>( &self, ) -> Result<Confined<Vec<u8>, 0, MAX>, SerializeError>
fn strict_serialize_to_file<const MAX: usize>( &self, path: impl AsRef<Path>, ) -> Result<(), SerializeError>
Source§impl StrictTuple for TypeSystem
impl StrictTuple for TypeSystem
const FIELD_COUNT: u8 = 1u8
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for TypeSystem
impl StrictType for TypeSystem
const STRICT_LIB_NAME: &'static str = STRICT_TYPES_LIB
fn strict_name() -> Option<TypeName>
Source§impl Wrapper for TypeSystem
impl Wrapper for TypeSystem
Source§type Inner = Confined<BTreeMap<SemId, Ty<SemId>>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>
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
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
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
fn into_inner(self) -> <TypeSystem as Wrapper>::Inner
Unwraps the wrapper returning the inner type
impl DefaultBasedStrictDumb for TypeSystem
impl Eq for TypeSystem
impl StrictProduct for TypeSystem
impl StructuralPartialEq for TypeSystem
Auto Trait Implementations§
impl Freeze for TypeSystem
impl RefUnwindSafe for TypeSystem
impl Send for TypeSystem
impl Sync for TypeSystem
impl Unpin for TypeSystem
impl UnwindSafe for TypeSystem
Blanket Implementations§
Source§impl<T> AsciiArmor for Twhere
T: StrictArmor,
impl<T> AsciiArmor for Twhere
T: StrictArmor,
const PLATE_TITLE: &'static str = <T as StrictArmor>::PLATE_TITLE
type Err = StrictArmorError
fn ascii_armored_headers(&self) -> Vec<ArmorHeader>
fn to_ascii_armored_data(&self) -> Vec<u8> ⓘ
fn with_headers_data( headers: Vec<ArmorHeader>, data: Vec<u8>, ) -> Result<T, <T as AsciiArmor>::Err>
fn to_ascii_armored_string(&self) -> String
fn display_ascii_armored(&self) -> DisplayAsciiArmored<'_, Self>
fn ascii_armored_digest(&self) -> Option<Array<u8, 32>>
fn from_ascii_armored_str(s: &str) -> Result<Self, Self::Err>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.