Module prelude

Module prelude 

Source
Expand description

Each module should have its own prelude, which:

  • Adds preludes of upstream crates
  • Exports types with specific-enough names which mean they can safely be used downstream.

The idea is that we can just include the current crate’s prelude and avoid messing around with tons of includes. This makes refactors easier, and makes integration into the node less painful.

Re-exports§

pub use super::address::*;
pub use super::constants::*;
pub use super::crypto::*;
pub use super::data::manifest::prelude::*;
pub use super::data::scrypto::prelude::*;
pub use super::math::*;
pub use super::network::*;
pub use super::state::*;
pub use super::time::*;
pub use super::traits::*;
pub use super::types::*;

Modules§

basic
SBOR basic, no custom types
borrow
A module for working with borrowed data.
btree_map
btree_set
categorize
SBOR Categorize trait
codec
SBOR codec for core Rust types.
constants
SBOR constants
decode
SBOR decode trait.
decoder
SBOR decoding.
encode
SBOR encode trait.
encoded_wrappers
SBOR payload wrappers. These are new types around an encoded payload or sub-payload, with helper methods / traits implemented. They can be used as a more efficient wrapper a ScryptoValue if the content of that value is not needed.
encoder
SBOR encoding.
fmt
Utilities for formatting and printing Strings.
hash_map
hash_set
index_map
The methods and macros provided directly in this index_map module (new, with_capacity) work in both std and no-std modes - unlike the corresponding methods on IndexMap itself.
index_set
The methods and macros provided directly in this index_set module (new, with_capacity) work in both std and no-std modes - unlike the corresponding methods on IndexSet itself.
indexmap
IndexMap is a hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
mem
Basic functions for dealing with memory.
non_iter_map
paste
githubcrates-iodocs-rs
path
SBOR paths.
payload_validation
SBOR payload validation.
prelude
Each module should have its own prelude, which:
representations
SBOR textual representations
rust
A facade of Rust types.
schema
SBOR Schema
traversal
SBOR structured payload traversal.
value
SBOR value model and any decoding/encoding.
value_kind
SBOR value kinds - ie the types of value that are supported.
vec
A contiguous growable array type with heap-allocated contents, written Vec<T>.
vec_traits
Simpler traits specific to encodability/decodability against vec-based encoders/decoders
versioned
Data model versioning helper macro

Macros§

assert_matches
Attempts to be a replacement for assert!(matches!(...)) but with better error messages, and allowing further code on success.
btreemap
btreeset
create_well_known_lookup
define_single_versioned
This macro is intended for creating a data model which supports versioning. This is useful for creating an SBOR data model which can be updated in future.
define_versioned
This macro is intended for creating a data model which supports versioning. This is useful for creating an SBOR data model which can be updated in future. In future, enum variants can be added, and automatically mapped to.
define_wrapped_hash
eager_replace
NOTE: This should probably be moved out of sbor to its own crate.
format
Creates a String using interpolation of runtime expressions.
hashmap
hashset
i
Creates a safe integer from literals. You must specify the type of the integer you want to create.
indexmap
indexset
labelled_resolvable_using_resolvable_impl
labelled_resolvable_with_identity_impl
look_up_type
manifest_args
numeric_validation_match
resolvable_with_identity_impl
resolvable_with_try_into_impls
return_type_mismatch_error
scrypto_args
to_manifest_value_and_unwrap
vec
Creates a Vec containing the arguments.

Structs§

Arc
A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
ArrayData
BTreeMap
An ordered map based on a B-Tree.
BTreeSet
An ordered set based on a B-Tree.
BorrowError
An error returned by RefCell::try_borrow.
BorrowMutError
An error returned by RefCell::try_borrow_mut.
Box
A pointer type that uniquely owns a heap allocation of type T.
Cell
A mutable memory location.
ContextDisplayable
EnumVariantData
EnumVariantValue
LazyCell
A value which is initialized on the first access.
LengthValidation
Represents additional validation that should be performed on the size.
LinkedList
A doubly-linked list with owned nodes.
LocatedValidationError
MapData
NameChangeError
NamedSchemaVersions
A list of named comparable schemas, intended to capture various versions of the same schema over time.
NonIterMap
A thin wrapper around a HashMap, which guarantees that a HashMap usage will not result in a non-deterministic execution (simply by disallowing the iteration over its elements).
NovelTypeMetadata
This is the struct used in the Schema
NumericValidation
Represents additional validation that should be performed on the numeric value.
OnceCell
A cell which can nominally be written to only once.
OverlayingIterator
An iterator overlaying a “change on a value” (coming from the [overlaying] iterator) over a “base value” (coming from the [underlying] iterator). The one is matched to another by a K part (of the iterated tuple (K, V)), which both iterators are assumed to be ordered by.
OverlayingResultIterator
An iterator overlaying a “change on a value” (coming from the [overlaying] iterator) over a “base value” (coming from the [underlying] iterator) which may error. The one is matched to another by a K part (of the iterated tuple (K, V)), which both iterators are assumed to be ordered by.
PhantomData
Zero-sized type used to mark things that “act like” they own a T.
RawPayload
A wrapper for a full encoded SBOR payload, including the prefix byte.
RawValue
A wrapper for a reference to a valid partial SBOR payload representing a single value.
Rc
A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.
Ref
Wraps a borrowed reference to a value in a RefCell box. A wrapper type for an immutably borrowed value from a RefCell<T>.
RefCell
A mutable memory location with dynamically checked borrow rules
RefMut
A wrapper type for a mutably borrowed value from a RefCell<T>.
SborFixedEnumVariant
SborPath
A series of indexes which describes some value in the sbor tree
SborPathBuf
SborRawPayload
A wrapper for a full encoded SBOR payload, including the prefix byte.
SborRawValue
A wrapper for a reference to a valid partial SBOR payload representing a single value.
SchemaComparisonCompletenessSettings
SchemaComparisonError
SchemaComparisonMetadataSettings
SchemaComparisonResult
SchemaComparisonSettings
SchemaComparisonStructureSettings
SchemaComparisonValidationSettings
SchemaContext
SchemaV1
An array of custom type kinds, and associated extra information which can attach to the type kinds
SingleTypeSchema
A serializable record of the schema of a single type. Intended for historical backwards compatibility checking of a single type.
String
A UTF-8–encoded, growable string.
TupleData
TypeAggregator
TypeCollectionSchema
A serializable record of the schema of a set of named types. Intended for historical backwards compatibility of a collection of types in a single schema.
TypeCompatibilityParameters
TypeData
Combines all data about a Type:
TypeMetadata
This enables the type to be represented as eg JSON Also used to facilitate type reconstruction
UnsafeCell
The core primitive for interior mutability in Rust.
Vec
A contiguous growable array type, written as Vec<T>, short for ‘vector’.
VecDecoder
A Decoder abstracts the logic for decoding basic types.
VecDeque
A double-ended queue implemented with a growable ring buffer.
VecEncoder
An Encoder abstracts the logic for writing core types into a byte buffer.
VersionedSchema
If you wish to get access to match on the versions, use .as_ref() or .as_mut().
WellKnownTypeId
SyncUnsafeCellExperimental
UnsafeCell, but Sync.

Enums§

ChildNames
Cow
A clone-on-write smart pointer.
DecodeError
Represents an error occurred during decoding.
EncodeError
Represents an error occurred during encoding.
LocalTypeId
The TypeId which is local to a given Schema. This is the SchemaTypeLink used in a linearized Schema to link TypeKinds.
NameChange
NameChangeRule
NoCustomExtension
NoCustomSchema
NoCustomTerminalValueRef
NoCustomTraversal
NoCustomTypeKind
NoCustomTypeKindLabel
NoCustomTypeValidation
NoCustomValue
NoCustomValueKind
Option
The Option type. See the module level documentation for more.
OwnedNameChange
PayloadValidationError
Result
Result is a type that represents either success (Ok) or failure (Err).
RustTypeId
This is a compile-time identifier for a given type, used by the type aggregator to uniquely identify a type.
SborValue
Represents any value conforming to the SBOR value model.
SchemaComparisonErrorDetail
SchemaValidationError
SchemaVersions
TypeKind
A schema for the values that a codec can decode / views as valid
TypeKindLabel
TypeValidation
Additional validation to apply to a payload of the given type, beyond validation from the TypeKind’s type structure.
ValidationChange
ValidationError
Value
Represents any value conforming to the SBOR value model.
ValueKind

Constants§

BASIC_SBOR_V1_MAX_DEPTH
BASIC_SBOR_V1_PAYLOAD_PREFIX
CUSTOM_VALUE_KIND_START
A custom type is an application defined type with special semantics.
MAX_NUMBER_OF_FIELDS
OPTION_VARIANT_NONE
OPTION_VARIANT_SOME
RESULT_VARIANT_ERR
RESULT_VARIANT_OK
VALUE_KIND_ARRAY
VALUE_KIND_BOOL
VALUE_KIND_ENUM
VALUE_KIND_I8
VALUE_KIND_I16
VALUE_KIND_I32
VALUE_KIND_I64
VALUE_KIND_I128
VALUE_KIND_MAP
VALUE_KIND_STRING
VALUE_KIND_TUPLE
VALUE_KIND_U8
VALUE_KIND_U16
VALUE_KIND_U32
VALUE_KIND_U64
VALUE_KIND_U128

Traits§

AsMut
Used to do a cheap mutable-to-mutable reference conversion.
AsRef
Used to do a cheap reference-to-reference conversion.
BasicCategorize
BasicDecode
BasicDescribe
BasicEncode
BasicSbor
BasicSborEnum
BasicSborEnumVariantFor
BasicSborTuple
BorrowingDecoder
Categorize
The Categorize trait marks a rust type as having a fixed value kind for SBOR encoding/decoding.
CheckedBackwardsCompatibleSchema
CheckedFixedSchema
Marker traits intended to be implemented by the SborAssert macros
Clone
A common trait that allows explicit creation of a duplicate value.
ComparableSchema
Marker trait for SingleTypeSchema and TypeCollectionSchema which includes named pointers to types, and can be used for comparisons of different versions of the same schema.
ContextualDisplay
This trait is used where context is required to correctly display a value.
ContextualTryFrom
ContextualTryInto
Copy
Types whose values can be duplicated simply by copying bits.
CustomExtension
CustomSchema
CustomTypeKind
CustomTypeKindLabel
CustomTypeValidation
CustomValue
Represents a custom SBOR value.
CustomValueKind
Debug
? formatting.
Decode
A data structure that can be decoded from a byte array using SBOR.
Decoder
Default
A trait for giving a type a useful default value.
Describe
The Describe trait allows a type to describe how to interpret and validate a corresponding SBOR payload.
Display
Format trait for an empty format, {}.
DoubleEndedIterator
An iterator able to yield elements from both ends.
Drop
Custom code within the destructor.
Encode
A data structure that can be serialized into a byte array using SBOR.
Encoder
Eq
Trait for comparisons corresponding to equivalence relations.
ExactSizeIterator
An iterator that knows its exact length.
Extend
Extend a collection with the contents of an iterator.
Fn
The version of the call operator that takes an immutable receiver.
FnMut
The version of the call operator that takes a mutable receiver.
FnOnce
The version of the call operator that takes a by-value receiver.
From
Used to do value-to-value conversions while consuming the input value. It is the reciprocal of Into.
FromIterator
Conversion from an Iterator.
FromStr
Parse a value from a string
Into
A value-to-value conversion that consumes the input value. The opposite of From.
IntoComparableSchema
IntoIterator
Conversion into an Iterator.
IsSborFixedEnumVariant
Iterator
A trait for dealing with iterators.
LabelResolver
LabelledResolvable
LabelledResolvable is a marker trait, serving a few purposes:
LabelledResolve
This trait is intended to be used as an impl argument in helper methods, to accept a wider range of arguments.
LabelledResolveFrom
The inverse trait of LabelledResolve.
NumericValidationBound
Ord
Trait for types that form a total order.
PartialEq
Trait for comparisons using the equality operator.
PartialOrd
Trait for types that form a partial order.
Resolvable
Resolvable is a marker trait, mainly to make resolution opt-in and to avoid polluting every type with a resolve method.
Resolve
This trait is intended to be used as an impl argument in helper methods, to accept a wider range of arguments.
ResolveFrom
The inverse trait of Resolve.
SborCustomValue
Represents a custom SBOR value.
SborEnum
Marker trait for encoding as an Sbor Enum
SborEnumVariantFor
This trait is output for unique unskipped single children of enum variants, when #[sbor(impl_variant_traits)] is specified on an Enum or #[sbor(impl_variant_trait)] is specified on a single Enum variant.
SborTuple
Marker trait for encoding as an Sbor Tuple
SchemaTypeLink
Marker trait for a link between TypeKinds:
Send
Types that can be transferred across thread boundaries.
Sized
Types with a constant size known at compile time.
Sync
Types for which it is safe to share references between threads.
ToOwned
A generalization of Clone to borrowed data.
ToString
A trait for converting a value to a String.
TryFrom
Simple and safe type conversions that may fail in a controlled way under some circumstances. It is the reciprocal of TryInto.
TryInto
An attempted conversion that consumes self, which may or may not be expensive.
UniqueVersioned
A trait for Versioned types which only have a single version.
Unpin
Types that do not require any pinning guarantees.
ValidatableCustomExtension
ValueVisitor
Versioned
A trait implemented by versioned types created via define_versioned and define_single_versioned.
VersionedSchemaVersion

Functions§

assert_type_backwards_compatibility
Designed for ensuring a type is only altered in ways which ensure backwards compatibility in SBOR serialization (i.e. that old payloads can be deserialized correctly by the latest type).
assert_type_collection_backwards_compatibility
Designed for ensuring a type collection is only altered in ways which ensure backwards compatibility in SBOR serialization (i.e. that old payloads of named types can be deserialized correctly by the latest schema).
basic_decode
Decode an instance of T from a slice.
basic_decode_with_depth_limit
basic_decode_with_depth_limit_and_nice_error
Decodes a data structure from a byte array.
basic_decode_with_nice_error
Decodes a data structure from a byte array.
basic_encode
Encode a T into byte array.
basic_encode_with_depth_limit
basic_payload_traverser
Creates a payload traverser from the buffer
combine
Combines a u8 with a u8 slice.
compare_single_type_schemas
Designed for basic comparisons between two types, e.g. equality checking.
compare_type_collection_schemas
Designed for basic comparisons between two type collection schemas, e.g. equality checking.
copy_u8_array
Copies a slice to a fixed-sized array.
drop
Disposes of a value.
generate_full_schema
You may wish to use the newer aggregator.generate_type_collection_schema() which, in tandom with add_named_root_type_and_descendents also captures named root types to give more structure to enable schema comparisons over time.
generate_full_schema_from_single_type
generate_single_type_schema
hash_map_new
Creates an empty map with capacity 0 and default Hasher
hash_map_with_capacity
Creates an empty map with given capacity and default Hasher
hash_set_new
Creates an empty set with capacity 0 and default Hasher
hash_set_with_capacity
Creates an empty set with given capacity and default Hasher
index_map_new
This is safe for std and no-std use cases (unlike IndexMap::new which disappears when std is not in the toolchain - see this article for deep technical reasons)
index_map_with_capacity
This is safe for std and no-std use cases (unlike IndexMap::with_capacity which disappears when std is not in the toolchain - see this article for deep technical reasons)
index_set_new
This is safe for std and no-std use cases (unlike IndexSet::new which disappears when std is not in the toolchain - see this article for deep technical reasons)
index_set_with_capacity
This is safe for std and no-std use cases (unlike IndexSet::with_capacity which disappears when std is not in the toolchain - see this article for deep technical reasons)
localize_well_known
localize_well_known_type_data
resolve_local_type_id
traverse_any
============================================== (DEPRECATED) TRAVERSAL
validate_childless_metadata
validate_container
validate_custom_type_validation
validate_enum_metadata
validate_field_names
validate_index
validate_partial_payload_against_schema
validate_payload_against_schema
validate_schema
validate_schema_enum_variant_name
validate_schema_field_name
validate_schema_type_name
validate_terminal_value
validate_terminal_value_batch
validate_tuple_metadata
validate_type_kind
validate_type_metadata_with_type_kind

Type Aliases§

AggregatorTypeData
AggregatorTypeId
A newer alias for RustTypeId.
AggregatorTypeKind
BasicAggregatorTypeData
BasicAggregatorTypeKind
BasicDecoder
BasicEncoder
BasicEnumVariantValue
BasicLocalTypeData
BasicLocalTypeKind
BasicOwnedRawPayload
BasicOwnedRawValue
BasicRawPayload
BasicRawValue
BasicSchema
BasicTraverser
BasicTypeAggregator
BasicTypeData
BasicTypeKind
BasicValue
BasicValueKind
BasicVersionedSchema
HashMap
HashSet
IndexMap
IndexSet
LocalTypeData
LocalTypeKind
Schema
SingleTypeSchemaCompatibilityParameters
TypeCollectionSchemaCompatibilityParameters
TypeHash

Derive Macros§

BasicCategorize
Derive code that returns the value kind - specifically for Basic SBOR.
BasicDecode
Derive code that decodes this data structure from a byte array - specifically for Basic SBOR.
BasicDescribe
Derive code that describes the type - specifically for Basic SBOR.
BasicEncode
Derive code that encodes this data structure - specifically for Basic SBOR.
BasicSbor
A shortcut for BasicCategorize, BasicEncode, BasicDecode, and BasicDescribe derives.
BasicSborAssertion
A macro for outputting tests and marker traits to assert that a type has maintained its shape over time.
Categorize
Derive code that returns the value kind.
Clone
Derive macro generating an impl of the trait Clone.
Copy
Derive macro generating an impl of the trait Copy.
Debug
Derive macro generating an impl of the trait Debug.
Decode
Derive code that decodes this data structure from a byte array.
Default
Derive macro generating an impl of the trait Default.
Describe
Derive code that describes this type.
Encode
Derive code that encodes this data structure
Eq
Derive macro generating an impl of the trait Eq.
ManifestCategorize
Derives code for categorizing a struct or enum with Manifest value model.
ManifestDecode
Derives code for decoding a struct or enum with Manifest value model.
ManifestEncode
Derives code for encoding a struct or enum with Manifest value model.
ManifestSbor
A shortcut for ManifestCategorize, ManifestEncode and ManifestDecode derives.
Ord
Derive macro generating an impl of the trait Ord. The behavior of this macro is described in detail here.
PartialEq
Derive macro generating an impl of the trait PartialEq. The behavior of this macro is described in detail here.
PartialOrd
Derive macro generating an impl of the trait PartialOrd. The behavior of this macro is described in detail here.
PermitSborAttributes
An empty derive which exists solely to allow the helper “sbor” attribute to be used without generating a compile error.
Sbor
A shortcut for Categorize, Encode, Decode, and Describe derives.
ScryptoCategorize
Derives code for categorizing a struct or enum with Scrypto value model.
ScryptoDecode
Derives code for decoding a struct or enum with Scrypto value model.
ScryptoDescribe
Derives code for describing a struct or enum with Scrypto schema.
ScryptoEncode
Derives code for encoding a struct or enum with Scrypto value model.
ScryptoEvent
Derive code for implementing the required logic to mark a type as being an event.
ScryptoSbor
A shortcut for ScryptoCategorize, ScryptoEncode, ScryptoDecode, and ScryptoDescribe derives.
ScryptoSborAssertion
A macro for outputting tests and marker traits to assert that a type has maintained its shape over time.