rocketmq_remoting/protocol/request_type.rs
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17use std::fmt::Display;
18
19#[derive(Debug, PartialEq, Eq, Clone, Copy)]
20pub enum RequestType {
21 Stream,
22}
23
24impl Display for RequestType {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 match self {
27 RequestType::Stream => write!(f, "STREAM"),
28 }
29 }
30}
31
32impl RequestType {
33 pub fn value_of(code: u8) -> Option<Self> {
34 match code {
35 0 => Some(RequestType::Stream),
36 _ => None,
37 }
38 }
39
40 pub fn get_code(&self) -> u8 {
41 match self {
42 RequestType::Stream => 0,
43 }
44 }
45}