mod.rs

Overview

This file defines core abstractions and implementations related to message handling within the system. It provides a Message trait describing the interface for message types, and a concrete wrapper struct WrappedMessage that encapsulates a low-level message type from the tvm_block crate. The wrapper facilitates ordering, equality checks, serialization, deserialization, and exposes the message destination account identifier. The file also includes utility modules and test stubs to support message-related functionality.

Modules

Traits and Structures

Message Trait

Defines a contract for message types to implement. It is generic over an associated AccountId type and requires implementations to support debugging, cloning, thread safety (Sync + Send), and serialization/deserialization via Serde.

Methods

Usage

Implementations of this trait represent different message types in the system, providing a uniform interface to access their destination and enabling polymorphic handling of messages.


WrappedMessage Struct

A concrete wrapper around the tvm_block::Message type. Provides implementations for traits such as equality, ordering, debugging, and Serde serialization/deserialization. This struct standardizes message behavior and facilitates integration with the system's messaging workflows.

Fields

Trait Implementations

Methods

Usage Example

let wrapped_msg = WrappedMessage { message: some_tvm_message };
let dest = wrapped_msg.destination();
println!("Destination: {:?}", dest);

let serialized = serde_json::to_string(&wrapped_msg).unwrap();
let deserialized: WrappedMessage = serde_json::from_str(&serialized).unwrap();
assert_eq!(wrapped_msg, deserialized);

Implementation Details and Algorithms

Interaction with Other System Components

Data Structures

classDiagram
class WrappedMessage {
- message: tvm_block::Message
+ wrap_serialize()
+ wrap_deserialize()
+ destination()
+ cmp()
+ eq()
}
WrappedMessage --|> Message
class Message {
<<trait>>
+ destination()
}
WrappedMessage ..> WrappedMessageData : uses
WrappedMessageData : data: Vec<u8>

The diagram illustrates:

Summary of Key Components

Component

Description

Key Functions / Methods

Message trait

Interface for message types, defines destination retrieval

destination()

WrappedMessage

Wrapper for tvm_block::Message providing ordering, serialization, and trait implementations

wrap_serialize(), wrap_deserialize(), destination(), cmp(), eq()

WrappedMessageData

Serialization helper struct containing raw message bytes

N/A (data container only)


This file serves as a foundational element for message handling, enabling consistent message representation, serialization, ordering, and destination extraction within the system. It integrates tightly with the external tvm_block and tvm_types crates to leverage blockchain VM message primitives.