1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
#[allow(dead_code)] #[allow(unknown_lints)] #[allow(clippy::all)] #[allow(renamed_and_removed_lints)] #[allow(bare_trait_objects)] #[allow(deprecated)] mod protos { include!(concat!(env!("OUT_DIR"), "/protos/mod.rs")); use raft_proto::eraftpb; } pub use protos::*; #[cfg(feature = "prost-codec")] pub mod prost_adapt { use crate::backup::{error, ClusterIdError, Error}; use crate::import_kvpb::{write_engine_request, WriteBatch, WriteEngineRequest, WriteHead}; use crate::import_sstpb::{upload_request, SstMeta, UploadRequest}; use crate::{errorpb, kvrpcpb}; impl UploadRequest { pub fn set_data(&mut self, v: Vec<u8>) { self.chunk = Some(upload_request::Chunk::Data(v)); } pub fn get_data(&self) -> &[u8] { match &self.chunk { Some(upload_request::Chunk::Data(v)) => v, _ => &[], } } pub fn set_meta(&mut self, v: SstMeta) { self.chunk = Some(upload_request::Chunk::Meta(v)); } pub fn get_meta(&self) -> &SstMeta { match &self.chunk { Some(upload_request::Chunk::Meta(v)) => v, _ => SstMeta::default_ref(), } } pub fn has_meta(&self) -> bool { match self.chunk { Some(upload_request::Chunk::Meta(_)) => true, _ => false, } } } impl WriteEngineRequest { pub fn set_head(&mut self, v: WriteHead) { self.chunk = Some(write_engine_request::Chunk::Head(v)); } pub fn get_head(&self) -> &WriteHead { match &self.chunk { Some(write_engine_request::Chunk::Head(v)) => v, _ => WriteHead::default_ref(), } } pub fn has_head(&self) -> bool { match self.chunk { Some(write_engine_request::Chunk::Head(_)) => true, _ => false, } } pub fn set_batch(&mut self, v: WriteBatch) { self.chunk = Some(write_engine_request::Chunk::Batch(v)); } pub fn get_batch(&self) -> &WriteBatch { match &self.chunk { Some(write_engine_request::Chunk::Batch(v)) => v, _ => WriteBatch::default_ref(), } } pub fn has_batch(&self) -> bool { match self.chunk { Some(write_engine_request::Chunk::Batch(_)) => true, _ => false, } } pub fn take_batch(&mut self) -> WriteBatch { if self.has_batch() { match self.chunk.take() { Some(write_engine_request::Chunk::Batch(v)) => v, _ => unreachable!(), } } else { WriteBatch::default() } } } impl Error { pub fn set_region_error(&mut self, v: errorpb::Error) { self.detail = Some(error::Detail::RegionError(v)); } pub fn set_kv_error(&mut self, v: kvrpcpb::KeyError) { self.detail = Some(error::Detail::KvError(v)); } pub fn set_cluster_id_error(&mut self, v: ClusterIdError) { self.detail = Some(error::Detail::ClusterIdError(v)); } pub fn get_region_error(&self) -> &errorpb::Error { match &self.detail { Some(error::Detail::RegionError(v)) => v, _ => errorpb::Error::default_ref(), } } pub fn get_kv_error(&self) -> &kvrpcpb::KeyError { match &self.detail { Some(error::Detail::KvError(v)) => v, _ => kvrpcpb::KeyError::default_ref(), } } pub fn get_cluster_id_error(&self) -> &ClusterIdError { match &self.detail { Some(error::Detail::ClusterIdError(v)) => v, _ => ClusterIdError::default_ref(), } } pub fn has_region_error(&self) -> bool { match self.detail { Some(error::Detail::RegionError(_)) => true, _ => false, } } pub fn has_kv_error(&self) -> bool { match self.detail { Some(error::Detail::KvError(_)) => true, _ => false, } } pub fn has_cluster_id_error(&self) -> bool { match self.detail { Some(error::Detail::ClusterIdError(_)) => true, _ => false, } } pub fn mut_region_error(&mut self) -> &mut errorpb::Error { if let Some(error::Detail::RegionError(_)) = self.detail { } else { self.detail = Some(error::Detail::RegionError(errorpb::Error::default())); } match self.detail { Some(error::Detail::RegionError(ref mut v)) => v, _ => unreachable!(), } } pub fn mut_kv_error(&mut self) -> &mut kvrpcpb::KeyError { if let Some(error::Detail::KvError(_)) = self.detail { } else { self.detail = Some(error::Detail::KvError(kvrpcpb::KeyError::default())); } match self.detail { Some(error::Detail::KvError(ref mut v)) => v, _ => unreachable!(), } } pub fn mut_cluster_id_error(&mut self) -> &mut ClusterIdError { if let Some(error::Detail::ClusterIdError(_)) = self.detail { } else { self.detail = Some(error::Detail::ClusterIdError(ClusterIdError::default())); } match self.detail { Some(error::Detail::ClusterIdError(ref mut v)) => v, _ => unreachable!(), } } } } pub mod cdc_adapt { #[cfg(not(feature = "prost-codec"))] pub mod pb { impl ::std::fmt::Debug for crate::cdcpb::Event_oneof_event { #[allow(unused_variables)] fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { let mut buf = String::new(); match self { crate::cdcpb::Event_oneof_event::Entries(v) => ::protobuf::PbPrint::fmt(v, "Entries", &mut buf), crate::cdcpb::Event_oneof_event::Admin(v) => ::protobuf::PbPrint::fmt(v, "Admin", &mut buf), crate::cdcpb::Event_oneof_event::Error(v) => ::protobuf::PbPrint::fmt(v, "Error", &mut buf), crate::cdcpb::Event_oneof_event::ResolvedTs(v) => ::protobuf::PbPrint::fmt(v, "ResolvedTs", &mut buf), crate::cdcpb::Event_oneof_event::LongTxn(v) => ::protobuf::PbPrint::fmt(v, "Long", &mut buf), } write!(f, "{}", buf) } } #[allow(dead_code)] fn assert_fmt_debug() { fn require_impl_debug<T: ::std::fmt::Debug>(_: T) {} require_impl_debug(crate::cdcpb::Event_oneof_event::Entries(::std::default::Default::default())); require_impl_debug(crate::cdcpb::ChangeDataEvent::default()); } } #[cfg(feature = "prost-codec")] pub mod prost { #[allow(dead_code)] fn assert_fmt_debug() { fn require_impl_debug<T: ::std::fmt::Debug>(_: T) {} require_impl_debug(crate::cdcpb::event::Event::Entries(::std::default::Default::default())); require_impl_debug(crate::cdcpb::ChangeDataEvent::default()); } } }