rocketmq_client_rust/consumer/
pull_status.rs1use std::fmt::Display;
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
18pub enum PullStatus {
19 #[default]
21 Found,
22 NoNewMsg,
24 NoMatchedMsg,
26 OffsetIllegal,
28}
29
30impl From<i32> for PullStatus {
31 fn from(i: i32) -> Self {
32 match i {
33 0 => PullStatus::Found,
34 1 => PullStatus::NoNewMsg,
35 2 => PullStatus::NoMatchedMsg,
36 3 => PullStatus::OffsetIllegal,
37 _ => PullStatus::Found,
38 }
39 }
40}
41
42impl From<PullStatus> for i32 {
43 fn from(p: PullStatus) -> Self {
44 match p {
45 PullStatus::Found => 0,
46 PullStatus::NoNewMsg => 1,
47 PullStatus::NoMatchedMsg => 2,
48 PullStatus::OffsetIllegal => 3,
49 }
50 }
51}
52
53impl Display for PullStatus {
54 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55 match self {
56 PullStatus::Found => write!(f, "FOUND"),
57 PullStatus::NoNewMsg => write!(f, "NO_NEW_MSG"),
58 PullStatus::NoMatchedMsg => write!(f, "NO_MATCHED_MSG"),
59 PullStatus::OffsetIllegal => write!(f, "OFFSET_ILLEGAL"),
60 }
61 }
62}