rabbitmq_stream_protocol/request/
shims.rs1use crate::commands::create_super_stream::CreateSuperStreamCommand;
2use crate::commands::delete_super_stream::DeleteSuperStreamCommand;
3use crate::{
4 commands::{
5 close::CloseRequest, consumer_update_request::ConsumerUpdateRequestCommand,
6 create_stream::CreateStreamCommand, credit::CreditCommand,
7 declare_publisher::DeclarePublisherCommand, delete::Delete,
8 delete_publisher::DeletePublisherCommand,
9 exchange_command_versions::ExchangeCommandVersionsRequest, heart_beat::HeartBeatCommand,
10 metadata::MetadataCommand, open::OpenCommand, peer_properties::PeerPropertiesCommand,
11 publish::PublishCommand, query_offset::QueryOffsetRequest,
12 query_publisher_sequence::QueryPublisherRequest,
13 sasl_authenticate::SaslAuthenticateCommand, sasl_handshake::SaslHandshakeCommand,
14 store_offset::StoreOffset, subscribe::SubscribeCommand,
15 superstream_partitions::SuperStreamPartitionsRequest,
16 superstream_route::SuperStreamRouteRequest, tune::TunesCommand,
17 unsubscribe::UnSubscribeCommand, Command,
18 },
19 types::Header,
20 Request, RequestKind,
21};
22
23impl<T> From<T> for Request
24where
25 T: Into<RequestKind> + Command,
26{
27 fn from(cmd: T) -> Self {
28 Request {
29 header: Header::new(cmd.key(), cmd.version()),
30 kind: cmd.into(),
31 }
32 }
33}
34
35impl From<PeerPropertiesCommand> for RequestKind {
36 fn from(cmd: PeerPropertiesCommand) -> Self {
37 RequestKind::PeerProperties(cmd)
38 }
39}
40
41impl From<OpenCommand> for RequestKind {
42 fn from(cmd: OpenCommand) -> Self {
43 RequestKind::Open(cmd)
44 }
45}
46impl From<SaslHandshakeCommand> for RequestKind {
47 fn from(cmd: SaslHandshakeCommand) -> Self {
48 RequestKind::SaslHandshake(cmd)
49 }
50}
51impl From<SaslAuthenticateCommand> for RequestKind {
52 fn from(cmd: SaslAuthenticateCommand) -> Self {
53 RequestKind::SaslAuthenticate(cmd)
54 }
55}
56
57impl From<TunesCommand> for RequestKind {
58 fn from(cmd: TunesCommand) -> Self {
59 RequestKind::Tunes(cmd)
60 }
61}
62
63impl From<CreateStreamCommand> for RequestKind {
64 fn from(cmd: CreateStreamCommand) -> Self {
65 RequestKind::CreateStream(cmd)
66 }
67}
68impl From<Delete> for RequestKind {
69 fn from(cmd: Delete) -> Self {
70 RequestKind::Delete(cmd)
71 }
72}
73
74impl From<SubscribeCommand> for RequestKind {
75 fn from(cmd: SubscribeCommand) -> Self {
76 RequestKind::Subscribe(cmd)
77 }
78}
79
80impl From<CreditCommand> for RequestKind {
81 fn from(cmd: CreditCommand) -> Self {
82 RequestKind::Credit(cmd)
83 }
84}
85impl From<MetadataCommand> for RequestKind {
86 fn from(cmd: MetadataCommand) -> Self {
87 RequestKind::Metadata(cmd)
88 }
89}
90
91impl From<CloseRequest> for RequestKind {
92 fn from(cmd: CloseRequest) -> Self {
93 RequestKind::Close(cmd)
94 }
95}
96impl From<DeclarePublisherCommand> for RequestKind {
97 fn from(cmd: DeclarePublisherCommand) -> Self {
98 RequestKind::DeclarePublisher(cmd)
99 }
100}
101impl From<DeletePublisherCommand> for RequestKind {
102 fn from(cmd: DeletePublisherCommand) -> Self {
103 RequestKind::DeletePublisher(cmd)
104 }
105}
106
107impl From<HeartBeatCommand> for RequestKind {
108 fn from(cmd: HeartBeatCommand) -> Self {
109 RequestKind::Heartbeat(cmd)
110 }
111}
112
113impl From<PublishCommand> for RequestKind {
114 fn from(cmd: PublishCommand) -> Self {
115 RequestKind::Publish(cmd)
116 }
117}
118impl From<QueryOffsetRequest> for RequestKind {
119 fn from(cmd: QueryOffsetRequest) -> Self {
120 RequestKind::QueryOffset(cmd)
121 }
122}
123
124impl From<QueryPublisherRequest> for RequestKind {
125 fn from(cmd: QueryPublisherRequest) -> Self {
126 RequestKind::QueryPublisherSequence(cmd)
127 }
128}
129impl From<StoreOffset> for RequestKind {
130 fn from(cmd: StoreOffset) -> Self {
131 RequestKind::StoreOffset(cmd)
132 }
133}
134impl From<UnSubscribeCommand> for RequestKind {
135 fn from(cmd: UnSubscribeCommand) -> Self {
136 RequestKind::Unsubscribe(cmd)
137 }
138}
139impl From<ExchangeCommandVersionsRequest> for RequestKind {
140 fn from(cmd: ExchangeCommandVersionsRequest) -> Self {
141 RequestKind::ExchangeCommandVersions(cmd)
142 }
143}
144
145impl From<CreateSuperStreamCommand> for RequestKind {
146 fn from(cmd: CreateSuperStreamCommand) -> Self {
147 RequestKind::CreateSuperStream(cmd)
148 }
149}
150
151impl From<DeleteSuperStreamCommand> for RequestKind {
152 fn from(cmd: DeleteSuperStreamCommand) -> Self {
153 RequestKind::DeleteSuperStream(cmd)
154 }
155}
156
157impl From<SuperStreamPartitionsRequest> for RequestKind {
158 fn from(cmd: SuperStreamPartitionsRequest) -> Self {
159 RequestKind::SuperStreamPartitions(cmd)
160 }
161}
162
163impl From<SuperStreamRouteRequest> for RequestKind {
164 fn from(cmd: SuperStreamRouteRequest) -> Self {
165 RequestKind::SuperStreamRoute(cmd)
166 }
167}
168
169impl From<ConsumerUpdateRequestCommand> for RequestKind {
170 fn from(cmd: ConsumerUpdateRequestCommand) -> Self {
171 RequestKind::ConsumerUpdateRequest(cmd)
172 }
173}