Skip to main content

Module iota_primitives

Module iota_primitives 

Source
Expand description

JSON Schema and serialization adapter types for the IOTA JSON-RPC surface, applied at field sites via #[schemars(with = "...")] and #[serde_as(as = "...")]. Each adapter owns both the schemars::JsonSchema layer and the JSON serialization for its type, so the JSON-RPC wire format is defined in this crate rather than relying on the serde impls of the external iota-sdk-types crate.

To add a new adapter, prefer a unit marker struct with a manual JsonSchema impl (for explicit control over description, format, and shape) plus SerializeAs / DeserializeAs impls for the target type(s). String-like types reuse serde_with::DisplayFromStr so the format matches the type’s Display/FromStr; byte payloads reuse the fastcrypto encoders. The Move tag adapters reuse the shared, IOTA-specific formatting/parsing helpers from iota_types (which many other crates depend on) rather than duplicating that logic. Newtype wrappers (e.g. SequenceNumberString(u64)) are only appropriate when the wrapper itself is the serialised value.

Structs§

Base58
A schema type that defines the JSON representation of a Base58 encoded string. A custom JsonSchema impl is necessary to add the “base58” format to the schema.
Base64
A schema type that defines the JSON representation of a Base64 encoded string. A custom JsonSchema impl is necessary to add the “base64” format to the schema.
GenericSignature
A schema type that defines the JSON representation of a Base64 encoded signature.
Identifier
A schema type that defines the JSON representation of a Move identifier, and provides a string serialization usable via #[serde_as].
IotaAddress
A schema type that defines the JSON representation of the IotaAddress type.
ObjectId
A schema type that defines the JSON representation of the ObjectId type.
ProtocolVersion
A schema type that defines the JSON representation of the ProtocolVersion type as a string and provides an alternate serialization usable via #[serde_as].
SequenceNumberString
A schema type that defines the JSON representation of the [SequenceNumber] type as a string and provides an alternate serialization usable via #[serde_as].
SequenceNumberU64
A schema type that defines the JSON representation of the [SequenceNumber] type as a u64 integer and uses the default serialization.
StructTag
A schema type that defines the JSON representation of a Move StructTag as a string, and provides a string serialization usable via #[serde_as].
TypeTag
A schema type that defines the JSON representation of a Move TypeTag as a string, and provides a string serialization usable via #[serde_as].