@@ -126,6 +126,8 @@ impl<'a, T: 'a + Clone> Plugin<T> {
126
126
params : payload,
127
127
} ;
128
128
crate :: poll_loop!( {
129
+ // SAFETY: it is valid json and if we panic there is a buf somewhere
130
+ #[ allow( clippy:: unwrap_used) ]
129
131
writer. write_all( serde_json:: to_string( & request) . unwrap( ) . as_bytes( ) )
130
132
} ) ;
131
133
crate :: poll_loop!( { writer. flush( ) } ) ;
@@ -142,8 +144,12 @@ impl<'a, T: 'a + Clone> Plugin<T> {
142
144
) -> & mut Self {
143
145
let def_val = match opt_type {
144
146
"flag" | "bool" => {
147
+ // FIXME: remove unwrap and return the error
148
+ #[ allow( clippy:: unwrap_used) ]
145
149
def_val. map ( |val| serde_json:: json!( val. parse:: <bool >( ) . unwrap( ) ) )
146
150
}
151
+ // FIXME: remove unwrap and return the error
152
+ #[ allow( clippy:: unwrap_used) ]
147
153
"int" => def_val. map ( |val| serde_json:: json!( val. parse:: <i64 >( ) . unwrap( ) ) ) ,
148
154
"string" => def_val. map ( |val| serde_json:: json!( val) ) ,
149
155
_ => unreachable ! ( "{opt_type} not supported" ) ,
@@ -212,6 +218,9 @@ impl<'a, T: 'a + Clone> Plugin<T> {
212
218
}
213
219
214
220
fn handle_notification ( & ' a mut self , name : & str , params : serde_json:: Value ) {
221
+ // SAFETY: we register the notification and if we do not have inside the map
222
+ // this is a bug.
223
+ #[ allow( clippy:: unwrap_used) ]
215
224
let notification = self . rpc_notification . get ( name) . unwrap ( ) . clone ( ) ;
216
225
notification. call_void ( self , & params) ;
217
226
}
@@ -253,6 +262,8 @@ impl<'a, T: 'a + Clone> Plugin<T> {
253
262
match result {
254
263
Ok ( json_resp) => response[ "result" ] = json_resp. to_owned ( ) ,
255
264
Err ( json_err) => {
265
+ // SAFETY: should be valud json
266
+ #[ allow( clippy:: unwrap_used) ]
256
267
let err_resp = serde_json:: to_value ( json_err) . unwrap ( ) ;
257
268
response[ "error" ] = err_resp;
258
269
}
@@ -281,6 +292,8 @@ impl<'a, T: 'a + Clone> Plugin<T> {
281
292
asyncio. into_loop ( |buffer| {
282
293
#[ cfg( feature = "log" ) ]
283
294
log:: info!( "looping around the string: {buffer}" ) ;
295
+ // SAFETY: should be valud json
296
+ #[ allow( clippy:: unwrap_used) ]
284
297
let request: Request < serde_json:: Value > = serde_json:: from_str ( & buffer) . unwrap ( ) ;
285
298
if let Some ( id) = request. id {
286
299
// when the id is specified this is a RPC or Hook, so we need to return a response
@@ -293,6 +306,8 @@ impl<'a, T: 'a + Clone> Plugin<T> {
293
306
request. method,
294
307
rpc_response
295
308
) ;
309
+ // SAFETY: should be valud json
310
+ #[ allow( clippy:: unwrap_used) ]
296
311
Some ( serde_json:: to_string ( & rpc_response) . unwrap ( ) )
297
312
} else {
298
313
// in case of the id is None, we are receiving the notification, so the server is not
0 commit comments