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
String
s. - 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 onIndexMap
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 onIndexSet
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
- github crates-io docs-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’.
- Array
Data - BTree
Map - An ordered map based on a B-Tree.
- BTree
Set - An ordered set based on a B-Tree.
- Borrow
Error - An error returned by
RefCell::try_borrow
. - Borrow
MutError - 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.
- Context
Displayable - Enum
Variant Data - Enum
Variant Value - Lazy
Cell - A value which is initialized on the first access.
- Length
Validation - Represents additional validation that should be performed on the size.
- Linked
List - A doubly-linked list with owned nodes.
- Located
Validation Error - MapData
- Name
Change Error - Named
Schema Versions - A list of named comparable schemas, intended to capture various versions of the same schema over time.
- NonIter
Map - A thin wrapper around a
HashMap
, which guarantees that aHashMap
usage will not result in a non-deterministic execution (simply by disallowing the iteration over its elements). - Novel
Type Metadata - This is the struct used in the Schema
- Numeric
Validation - Represents additional validation that should be performed on the numeric value.
- Once
Cell - A cell which can nominally be written to only once.
- Overlaying
Iterator - 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 aK
part (of the iterated tuple(K, V)
), which both iterators are assumed to be ordered by. - Overlaying
Result Iterator - 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 aK
part (of the iterated tuple(K, V)
), which both iterators are assumed to be ordered by. - Phantom
Data - 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 aRefCell<T>
. - RefCell
- A mutable memory location with dynamically checked borrow rules
- RefMut
- A wrapper type for a mutably borrowed value from a
RefCell<T>
. - Sbor
Fixed Enum Variant - Sbor
Path - A series of indexes which describes some value in the sbor tree
- Sbor
Path Buf - Sbor
RawPayload - A wrapper for a full encoded SBOR payload, including the prefix byte.
- Sbor
RawValue - A wrapper for a reference to a valid partial SBOR payload representing a single value.
- Schema
Comparison Completeness Settings - Schema
Comparison Error - Schema
Comparison Metadata Settings - Schema
Comparison Result - Schema
Comparison Settings - Schema
Comparison Structure Settings - Schema
Comparison Validation Settings - Schema
Context - Schema
V1 - An array of custom type kinds, and associated extra information which can attach to the type kinds
- Single
Type Schema - 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.
- Tuple
Data - Type
Aggregator - Type
Collection Schema - 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.
- Type
Compatibility Parameters - Type
Data - Combines all data about a Type:
- Type
Metadata - This enables the type to be represented as eg JSON Also used to facilitate type reconstruction
- Unsafe
Cell - 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. - Versioned
Schema - If you wish to get access to match on the versions, use
.as_ref()
or.as_mut()
. - Well
Known Type Id - Sync
Unsafe Cell Experimental UnsafeCell
, butSync
.
Enums§
- Child
Names - Cow
- A clone-on-write smart pointer.
- Decode
Error - Represents an error occurred during decoding.
- Encode
Error - Represents an error occurred during encoding.
- Local
Type Id - The TypeId which is local to a given
Schema
. This is theSchemaTypeLink
used in a linearizedSchema
to linkTypeKind
s. - Name
Change - Name
Change Rule - NoCustom
Extension - NoCustom
Schema - NoCustom
Terminal Value Ref - NoCustom
Traversal - NoCustom
Type Kind - NoCustom
Type Kind Label - NoCustom
Type Validation - NoCustom
Value - NoCustom
Value Kind - Option
- The
Option
type. See the module level documentation for more. - Owned
Name Change - Payload
Validation Error - Result
Result
is a type that represents either success (Ok
) or failure (Err
).- Rust
Type Id - This is a compile-time identifier for a given type, used by the type aggregator to uniquely identify a type.
- Sbor
Value - Represents any value conforming to the SBOR value model.
- Schema
Comparison Error Detail - Schema
Validation Error - Schema
Versions - Type
Kind - A schema for the values that a codec can decode / views as valid
- Type
Kind Label - Type
Validation - Additional validation to apply to a payload of the given type, beyond validation from the
TypeKind
’s type structure. - Validation
Change - Validation
Error - Value
- Represents any value conforming to the SBOR value model.
- Value
Kind
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.
- Basic
Categorize - Basic
Decode - Basic
Describe - Basic
Encode - Basic
Sbor - Basic
Sbor Enum - Basic
Sbor Enum Variant For - Basic
Sbor Tuple - Borrowing
Decoder - Categorize
- The
Categorize
trait marks a rust type as having a fixed value kind for SBOR encoding/decoding. - Checked
Backwards Compatible Schema - Checked
Fixed Schema - Marker traits intended to be implemented by the SborAssert macros
- Clone
- A common trait that allows explicit creation of a duplicate value.
- Comparable
Schema - Marker trait for
SingleTypeSchema
andTypeCollectionSchema
which includes named pointers to types, and can be used for comparisons of different versions of the same schema. - Contextual
Display - This trait is used where context is required to correctly display a value.
- Contextual
TryFrom - Contextual
TryInto - Copy
- Types whose values can be duplicated simply by copying bits.
- Custom
Extension - Custom
Schema - Custom
Type Kind - Custom
Type Kind Label - Custom
Type Validation - Custom
Value - Represents a custom SBOR value.
- Custom
Value Kind - 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,
{}
. - Double
Ended Iterator - 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.
- Exact
Size Iterator - 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
. - From
Iterator - 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
. - Into
Comparable Schema - Into
Iterator - Conversion into an
Iterator
. - IsSbor
Fixed Enum Variant - Iterator
- A trait for dealing with iterators.
- Label
Resolver - Labelled
Resolvable LabelledResolvable
is a marker trait, serving a few purposes:- Labelled
Resolve - This trait is intended to be used as an
impl
argument in helper methods, to accept a wider range of arguments. - Labelled
Resolve From - The inverse trait of
LabelledResolve
. - Numeric
Validation Bound - Ord
- Trait for types that form a total order.
- Partial
Eq - Trait for comparisons using the equality operator.
- Partial
Ord - 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. - Resolve
From - The inverse trait of
Resolve
. - Sbor
Custom Value - Represents a custom SBOR value.
- Sbor
Enum - Marker trait for encoding as an Sbor Enum
- Sbor
Enum Variant For - 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. - Sbor
Tuple - Marker trait for encoding as an Sbor Tuple
- Schema
Type Link - Marker trait for a link between
TypeKind
s: - 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. - Unique
Versioned - A trait for Versioned types which only have a single version.
- Unpin
- Types that do not require any pinning guarantees.
- Validatable
Custom Extension - Value
Visitor - Versioned
- A trait implemented by versioned types created via
define_versioned
anddefine_single_versioned
. - Versioned
Schema Version
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 withadd_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§
- Aggregator
Type Data - Aggregator
Type Id - A newer alias for
RustTypeId
. - Aggregator
Type Kind - Basic
Aggregator Type Data - Basic
Aggregator Type Kind - Basic
Decoder - Basic
Encoder - Basic
Enum Variant Value - Basic
Local Type Data - Basic
Local Type Kind - Basic
Owned RawPayload - Basic
Owned RawValue - Basic
RawPayload - Basic
RawValue - Basic
Schema - Basic
Traverser - Basic
Type Aggregator - Basic
Type Data - Basic
Type Kind - Basic
Value - Basic
Value Kind - Basic
Versioned Schema - HashMap
- HashSet
- Index
Map - Index
Set - Local
Type Data - Local
Type Kind - Schema
- Single
Type Schema Compatibility Parameters - Type
Collection Schema Compatibility Parameters - Type
Hash
Derive Macros§
- Basic
Categorize - Derive code that returns the value kind - specifically for Basic SBOR.
- Basic
Decode - Derive code that decodes this data structure from a byte array - specifically for Basic SBOR.
- Basic
Describe - Derive code that describes the type - specifically for Basic SBOR.
- Basic
Encode - Derive code that encodes this data structure - specifically for Basic SBOR.
- Basic
Sbor - A shortcut for
BasicCategorize
,BasicEncode
,BasicDecode
, andBasicDescribe
derives. - Basic
Sbor Assertion - 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
. - Manifest
Categorize - Derives code for categorizing a struct or enum with Manifest value model.
- Manifest
Decode - Derives code for decoding a struct or enum with Manifest value model.
- Manifest
Encode - Derives code for encoding a struct or enum with Manifest value model.
- Manifest
Sbor - A shortcut for
ManifestCategorize
,ManifestEncode
andManifestDecode
derives. - Ord
- Derive macro generating an impl of the trait
Ord
. The behavior of this macro is described in detail here. - Partial
Eq - Derive macro generating an impl of the trait
PartialEq
. The behavior of this macro is described in detail here. - Partial
Ord - Derive macro generating an impl of the trait
PartialOrd
. The behavior of this macro is described in detail here. - Permit
Sbor Attributes - 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
, andDescribe
derives. - Scrypto
Categorize - Derives code for categorizing a struct or enum with Scrypto value model.
- Scrypto
Decode - Derives code for decoding a struct or enum with Scrypto value model.
- Scrypto
Describe - Derives code for describing a struct or enum with Scrypto schema.
- Scrypto
Encode - Derives code for encoding a struct or enum with Scrypto value model.
- Scrypto
Event - Derive code for implementing the required logic to mark a type as being an event.
- Scrypto
Sbor - A shortcut for
ScryptoCategorize
,ScryptoEncode
,ScryptoDecode
, andScryptoDescribe
derives. - Scrypto
Sbor Assertion - A macro for outputting tests and marker traits to assert that a type has maintained its shape over time.