Skip to main content

Module codec

Module codec 

Source
Expand description

tarpc transport codec for RYO RPC communication.

§Why MessagePackNamed?

RYO uses MessagePack for RPC serialization via tarpc. There are two serialization modes:

ModeSerializationskip_serializing_if
Array-based (default)[value1, value2, ...]Incompatible
Named (map-based){"field1": value1, ...}Compatible

Many response types use #[serde(skip_serializing_if = "...")] to reduce payload size. This requires named serialization where fields are identified by name, not position.

Using array-based serialization with skip_serializing_if causes deserialization failures:

invalid type: boolean `false`, expected a sequence

§Usage

Always use the helper functions to create transports:

use ryo_app::codec::create_client_transport;
use tokio::net::UnixStream;

let stream = UnixStream::connect(socket_path).await?;
let transport = create_client_transport(stream);
let client = RyoServiceClient::new(config, transport).spawn();

§Important

DO NOT use tokio_serde::formats::MessagePack::default() directly. It uses array-based serialization which is incompatible with skip_serializing_if.

Structs§

MessagePackNamed
MessagePack codec with named (map-based) serialization.

Functions§

create_client_transport
Create a tarpc transport with the correct codec for client-side use.
create_server_transport
Create a tarpc transport with the correct codec for server-side use.