thrifty/message
Types
Message header structure.
pub type MessageHeader {
MessageHeader(
name: String,
message_type: MessageType,
sequence_id: Int,
)
}
Constructors
-
MessageHeader( name: String, message_type: MessageType, sequence_id: Int, )
Message type enumeration for Thrift messages.
pub type MessageType {
Call
Reply
Exception
Oneway
}
Constructors
-
Call -
Reply -
Exception -
Oneway
Values
pub fn decode_message_header(
data: BitArray,
byte_pos: Int,
) -> Result(#(MessageHeader, Int), types.DecodeError)
Decode a Thrift message header from data starting at byte_pos.
Inputs
data: theBitArraycontaining the encoded message header and payload.byte_pos: byte offset where the header begins.
Outputs
Ok(#(MessageHeader, next_byte_position))on success wherenext_byte_positionpoints after the method name bytes.Error(types.DecodeError)on protocol mismatch, unsupported version, invalid varint encodings, or invalid UTF-8 in the method name.
pub fn encode_message_header(header: MessageHeader) -> BitArray
Encode a Thrift message header to a BitArray using Compact Protocol
framing.
Inputs
header: aMessageHeaderrecord with name, message_type and sequence id.
Outputs
- Returns a
BitArraycontaining the protocol id, version/type byte, varint-encoded sequence id, varint length of method name and UTF-8 bytes for the method name.
Format
- Protocol ID: 0x82 (1 byte)
- Version & Type: (version << 5) | type (1 byte, version=1)
- Sequence ID: varint i32
- Method name: length (varint) + UTF-8 bytes