@@ -13,9 +13,9 @@ pub unsafe extern "C" fn taos_errno(res: *mut TAOS_RES) -> c_int {
1313 return errno ( ) ;
1414 }
1515
16- match ( res as * mut MaybeError < ( ) > )
16+ match ( res as * mut TaosMaybeError < ( ) > )
1717 . as_ref ( )
18- . and_then ( MaybeError :: errno)
18+ . and_then ( TaosMaybeError :: errno)
1919 {
2020 Some ( errno) => format_errno ( errno) ,
2121 _ => Code :: SUCCESS . into ( ) ,
@@ -31,9 +31,9 @@ pub unsafe extern "C" fn taos_errstr(res: *mut TAOS_RES) -> *const c_char {
3131 return errstr ( ) ;
3232 }
3333
34- match ( res as * mut MaybeError < ( ) > )
34+ match ( res as * mut TaosMaybeError < ( ) > )
3535 . as_ref ( )
36- . and_then ( MaybeError :: errstr)
36+ . and_then ( TaosMaybeError :: errstr)
3737 {
3838 Some ( err) => err,
3939 _ => EMPTY . as_ptr ( ) ,
@@ -48,7 +48,7 @@ thread_local! {
4848 static ERRSTR : RefCell <[ u8 ; MAX_ERRSTR_LEN ] > = const { RefCell :: new( [ 0 ; MAX_ERRSTR_LEN ] ) } ;
4949}
5050
51- pub fn set_err_and_get_code ( err : Error ) -> i32 {
51+ pub fn set_err_and_get_code ( err : TaosError ) -> i32 {
5252 ERRNO . with ( |errno| {
5353 let code: u32 = err. code . into ( ) ;
5454 * errno. borrow_mut ( ) = ( code | 0x80000000 ) as i32 ;
@@ -81,13 +81,13 @@ pub fn format_errno(errno: i32) -> i32 {
8181}
8282
8383#[ derive( Debug ) ]
84- pub struct MaybeError < T > {
85- err : Option < Error > ,
84+ pub struct TaosMaybeError < T > {
85+ err : Option < TaosError > ,
8686 data : * mut T ,
8787 type_id : & ' static str ,
8888}
8989
90- impl < T > MaybeError < T > {
90+ impl < T > TaosMaybeError < T > {
9191 pub fn errno ( & self ) -> Option < i32 > {
9292 self . err . as_ref ( ) . map ( |err| err. code . into ( ) )
9393 }
@@ -105,7 +105,7 @@ impl<T> MaybeError<T> {
105105 }
106106}
107107
108- impl < T > Drop for MaybeError < T > {
108+ impl < T > Drop for TaosMaybeError < T > {
109109 fn drop ( & mut self ) {
110110 if !self . data . is_null ( ) {
111111 trace ! ( self . type_id, "drop MaybeError" ) ;
@@ -114,7 +114,7 @@ impl<T> Drop for MaybeError<T> {
114114 }
115115}
116116
117- impl < T > From < T > for MaybeError < T > {
117+ impl < T > From < T > for TaosMaybeError < T > {
118118 fn from ( value : T ) -> Self {
119119 Self {
120120 err : None ,
@@ -124,7 +124,7 @@ impl<T> From<T> for MaybeError<T> {
124124 }
125125}
126126
127- impl < T > From < Box < T > > for MaybeError < T > {
127+ impl < T > From < Box < T > > for TaosMaybeError < T > {
128128 fn from ( value : Box < T > ) -> Self {
129129 Self {
130130 err : None ,
@@ -134,9 +134,9 @@ impl<T> From<Box<T>> for MaybeError<T> {
134134 }
135135}
136136
137- impl < T , E > From < Result < T , E > > for MaybeError < T >
137+ impl < T , E > From < Result < T , E > > for TaosMaybeError < T >
138138where
139- E : Into < Error > ,
139+ E : Into < TaosError > ,
140140{
141141 fn from ( value : Result < T , E > ) -> Self {
142142 match value {
@@ -154,9 +154,9 @@ where
154154 }
155155}
156156
157- impl < T , E > From < Result < Box < T > , E > > for MaybeError < T >
157+ impl < T , E > From < Result < Box < T > , E > > for TaosMaybeError < T >
158158where
159- E : Into < Error > ,
159+ E : Into < TaosError > ,
160160{
161161 fn from ( value : Result < Box < T > , E > ) -> Self {
162162 match value {
@@ -175,13 +175,13 @@ where
175175}
176176
177177#[ derive( Debug ) ]
178- pub struct Error {
178+ pub struct TaosError {
179179 code : Code ,
180180 message : CString ,
181181 source : Option < Box < dyn std:: error:: Error > > ,
182182}
183183
184- impl Error {
184+ impl TaosError {
185185 pub fn new ( code : Code , message : & str ) -> Self {
186186 Self {
187187 code,
@@ -191,8 +191,8 @@ impl Error {
191191 }
192192}
193193
194- impl From < & Error > for Error {
195- fn from ( err : & Error ) -> Self {
194+ impl From < & TaosError > for TaosError {
195+ fn from ( err : & TaosError ) -> Self {
196196 Self {
197197 code : err. code ,
198198 message : err. message . clone ( ) ,
@@ -201,19 +201,19 @@ impl From<&Error> for Error {
201201 }
202202}
203203
204- impl std:: fmt:: Display for Error {
204+ impl std:: fmt:: Display for TaosError {
205205 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
206206 write ! ( f, "[{:#06X}] {}" , self . code, self . message. to_str( ) . unwrap( ) )
207207 }
208208}
209209
210- impl std:: error:: Error for Error {
210+ impl std:: error:: Error for TaosError {
211211 fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
212212 self . source . as_ref ( ) . map ( |e| e. as_ref ( ) )
213213 }
214214}
215215
216- impl From < Box < dyn std:: error:: Error > > for Error {
216+ impl From < Box < dyn std:: error:: Error > > for TaosError {
217217 fn from ( err : Box < dyn std:: error:: Error > ) -> Self {
218218 Self {
219219 code : Code :: FAILED ,
@@ -223,7 +223,7 @@ impl From<Box<dyn std::error::Error>> for Error {
223223 }
224224}
225225
226- impl From < std:: str:: Utf8Error > for Error {
226+ impl From < std:: str:: Utf8Error > for TaosError {
227227 fn from ( err : std:: str:: Utf8Error ) -> Self {
228228 Self {
229229 code : Code :: FAILED ,
@@ -233,7 +233,7 @@ impl From<std::str::Utf8Error> for Error {
233233 }
234234}
235235
236- impl From < std:: string:: FromUtf8Error > for Error {
236+ impl From < std:: string:: FromUtf8Error > for TaosError {
237237 fn from ( err : std:: string:: FromUtf8Error ) -> Self {
238238 Self {
239239 code : Code :: FAILED ,
@@ -243,7 +243,7 @@ impl From<std::string::FromUtf8Error> for Error {
243243 }
244244}
245245
246- impl From < taos_query:: DsnError > for Error {
246+ impl From < taos_query:: DsnError > for TaosError {
247247 fn from ( err : taos_query:: DsnError ) -> Self {
248248 use taos_ws:: query:: asyn:: WS_ERROR_NO ;
249249 Self {
@@ -254,7 +254,7 @@ impl From<taos_query::DsnError> for Error {
254254 }
255255}
256256
257- impl From < taos_query:: common:: SmlDataBuilderError > for Error {
257+ impl From < taos_query:: common:: SmlDataBuilderError > for TaosError {
258258 fn from ( err : taos_query:: common:: SmlDataBuilderError ) -> Self {
259259 Self {
260260 code : Code :: FAILED ,
@@ -264,7 +264,7 @@ impl From<taos_query::common::SmlDataBuilderError> for Error {
264264 }
265265}
266266
267- impl From < taos_ws:: Error > for Error {
267+ impl From < taos_ws:: Error > for TaosError {
268268 fn from ( e : taos_ws:: Error ) -> Self {
269269 Self {
270270 code : e. errno ( ) ,
@@ -274,7 +274,7 @@ impl From<taos_ws::Error> for Error {
274274 }
275275}
276276
277- impl From < taos_ws:: query:: Error > for Error {
277+ impl From < taos_ws:: query:: Error > for TaosError {
278278 fn from ( err : taos_ws:: query:: Error ) -> Self {
279279 Self {
280280 code : err. errno ( ) ,
@@ -284,7 +284,7 @@ impl From<taos_ws::query::Error> for Error {
284284 }
285285}
286286
287- impl From < taos_error:: Error > for Error {
287+ impl From < taos_error:: Error > for TaosError {
288288 fn from ( err : taos_error:: Error ) -> Self {
289289 Self {
290290 code : err. code ( ) ,
@@ -304,7 +304,7 @@ mod tests {
304304 #[ test]
305305 fn test_set_err_and_get_code ( ) {
306306 unsafe {
307- let err = Error :: new ( Code :: SUCCESS , "test error" ) ;
307+ let err = TaosError :: new ( Code :: SUCCESS , "test error" ) ;
308308 let code = set_err_and_get_code ( err) ;
309309 assert_eq ! ( code as u32 , 0x80000000 ) ;
310310
0 commit comments