Skip to main content

rocketmq_protocol/rpc/
rpc_request.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
9use std::any::Any;
10
11use crate::protocol::header::message_operation_header::TopicRequestHeaderTrait;
12use crate::protocol::CommandCustomHeader;
13
14pub struct RpcRequest<H> {
15    pub code: i32,
16    pub header: H,
17    pub body: Option<Box<dyn Any + Send>>,
18}
19
20impl<H> RpcRequest<H>
21where
22    H: CommandCustomHeader + TopicRequestHeaderTrait,
23{
24    pub fn new(code: i32, header: H, body: Option<Box<dyn Any + Send>>) -> Self {
25        Self { code, header, body }
26    }
27}