rocketmq_protocol/lib.rs
1// Copyright 2023 The RocketMQ Rust Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Runtime-neutral RocketMQ wire protocol contracts.
16//!
17//! This crate defines request and response codes, [`RemotingCommand`] frames,
18//! custom-header codecs, protocol bodies, compression, and trace encoding.
19//! Its main entry points include [`RequestCode`], [`RemotingCommand`],
20//! [`CommandCustomHeader`], [`HeaderCodec`], and [`RpcRequestHeader`].
21//!
22//! Enable the `simd` feature to use accelerated protocol decoding paths.
23
24mod contract;
25mod error;
26
27pub mod code;
28pub mod common;
29pub mod protocol;
30pub mod rpc;
31pub mod trace;
32
33pub use rocketmq_model::version;
34
35pub use code::request_code::RequestCode;
36pub use code::response_code::RemotingSysResponseCode;
37pub use contract::ProtocolContractViolation;
38pub use protocol::command_custom_header::CommandCustomHeader;
39pub use protocol::command_custom_header::FromMap;
40pub use protocol::command_custom_header::HeaderEncodeCapability;
41pub use protocol::command_custom_header::HeaderMap;
42pub use protocol::encoded_frame::EncodedFrame;
43pub use protocol::encoded_frame::EncodedFrameHead;
44pub use protocol::header_codec::HeaderCodec;
45pub use protocol::remoting_command::RemotingCommand;
46pub use protocol::rocketmq_serializable;
47pub use rpc::rpc_request_header::RpcRequestHeader;
48pub use rpc::topic_request_header::TopicRequestHeader;
49
50/// Stable implementation details used by RocketMQ derive macros.
51#[doc(hidden)]
52pub mod __request_header_codec {
53 pub use bytes::BytesMut;
54 pub use cheetah_string::CheetahString;
55 pub use rocketmq_error::Error;
56
57 /// Creates a descriptor-backed header validation error for generated codecs.
58 pub fn request_header_error(_detail: impl Into<String>) -> Error {
59 crate::error::request_header_failure()
60 }
61}