1818//! [VhostUserBackend]: trait.VhostUserBackend.html
1919//! [VhostUserBackendMut]: trait.VhostUserBackendMut.html
2020
21- use std:: io;
21+ use std:: io:: Result ;
2222use std:: ops:: Deref ;
23- use std:: result;
2423use std:: sync:: { Arc , Mutex , RwLock } ;
2524
2625use vhost:: vhost_user:: message:: VhostUserProtocolFeatures ;
@@ -71,12 +70,12 @@ where
7170 ///
7271 /// A default implementation is provided as we cannot expect all backends to implement this
7372 /// function.
74- fn set_config ( & self , _offset : u32 , _buf : & [ u8 ] ) -> result :: Result < ( ) , io :: Error > {
73+ fn set_config ( & self , _offset : u32 , _buf : & [ u8 ] ) -> Result < ( ) > {
7574 Ok ( ( ) )
7675 }
7776
7877 /// Update guest memory regions.
79- fn update_memory ( & self , mem : GM < B > ) -> result :: Result < ( ) , io :: Error > ;
78+ fn update_memory ( & self , mem : GM < B > ) -> Result < ( ) > ;
8079
8180 /// Set handler for communicating with the master by the slave communication channel.
8281 ///
@@ -115,7 +114,7 @@ where
115114 evset : EventSet ,
116115 vrings : & [ V ] ,
117116 thread_id : usize ,
118- ) -> result :: Result < bool , io :: Error > ;
117+ ) -> Result < bool > ;
119118}
120119
121120/// Trait without interior mutability for vhost user backend servers to implement concrete services.
@@ -154,12 +153,12 @@ where
154153 ///
155154 /// A default implementation is provided as we cannot expect all backends to implement this
156155 /// function.
157- fn set_config ( & mut self , _offset : u32 , _buf : & [ u8 ] ) -> result :: Result < ( ) , io :: Error > {
156+ fn set_config ( & mut self , _offset : u32 , _buf : & [ u8 ] ) -> Result < ( ) > {
158157 Ok ( ( ) )
159158 }
160159
161160 /// Update guest memory regions.
162- fn update_memory ( & mut self , mem : GM < B > ) -> result :: Result < ( ) , io :: Error > ;
161+ fn update_memory ( & mut self , mem : GM < B > ) -> Result < ( ) > ;
163162
164163 /// Set handler for communicating with the master by the slave communication channel.
165164 ///
@@ -198,7 +197,7 @@ where
198197 evset : EventSet ,
199198 vrings : & [ V ] ,
200199 thread_id : usize ,
201- ) -> result :: Result < bool , io :: Error > ;
200+ ) -> Result < bool > ;
202201}
203202
204203impl < T : VhostUserBackend < V , B > , V , B > VhostUserBackend < V , B > for Arc < T >
@@ -234,11 +233,11 @@ where
234233 self . deref ( ) . get_config ( offset, size)
235234 }
236235
237- fn set_config ( & self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) , io :: Error > {
236+ fn set_config ( & self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) > {
238237 self . deref ( ) . set_config ( offset, buf)
239238 }
240239
241- fn update_memory ( & self , mem : GM < B > ) -> Result < ( ) , io :: Error > {
240+ fn update_memory ( & self , mem : GM < B > ) -> Result < ( ) > {
242241 self . deref ( ) . update_memory ( mem)
243242 }
244243
@@ -260,7 +259,7 @@ where
260259 evset : EventSet ,
261260 vrings : & [ V ] ,
262261 thread_id : usize ,
263- ) -> Result < bool , io :: Error > {
262+ ) -> Result < bool > {
264263 self . deref ( )
265264 . handle_event ( device_event, evset, vrings, thread_id)
266265 }
@@ -299,11 +298,11 @@ where
299298 self . lock ( ) . unwrap ( ) . get_config ( offset, size)
300299 }
301300
302- fn set_config ( & self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) , io :: Error > {
301+ fn set_config ( & self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) > {
303302 self . lock ( ) . unwrap ( ) . set_config ( offset, buf)
304303 }
305304
306- fn update_memory ( & self , mem : GM < B > ) -> Result < ( ) , io :: Error > {
305+ fn update_memory ( & self , mem : GM < B > ) -> Result < ( ) > {
307306 self . lock ( ) . unwrap ( ) . update_memory ( mem)
308307 }
309308
@@ -325,7 +324,7 @@ where
325324 evset : EventSet ,
326325 vrings : & [ V ] ,
327326 thread_id : usize ,
328- ) -> Result < bool , io :: Error > {
327+ ) -> Result < bool > {
329328 self . lock ( )
330329 . unwrap ( )
331330 . handle_event ( device_event, evset, vrings, thread_id)
@@ -365,11 +364,11 @@ where
365364 self . read ( ) . unwrap ( ) . get_config ( offset, size)
366365 }
367366
368- fn set_config ( & self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) , io :: Error > {
367+ fn set_config ( & self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) > {
369368 self . write ( ) . unwrap ( ) . set_config ( offset, buf)
370369 }
371370
372- fn update_memory ( & self , mem : GM < B > ) -> Result < ( ) , io :: Error > {
371+ fn update_memory ( & self , mem : GM < B > ) -> Result < ( ) > {
373372 self . write ( ) . unwrap ( ) . update_memory ( mem)
374373 }
375374
@@ -391,7 +390,7 @@ where
391390 evset : EventSet ,
392391 vrings : & [ V ] ,
393392 thread_id : usize ,
394- ) -> Result < bool , io :: Error > {
393+ ) -> Result < bool > {
395394 self . write ( )
396395 . unwrap ( )
397396 . handle_event ( device_event, evset, vrings, thread_id)
@@ -402,7 +401,6 @@ where
402401pub mod tests {
403402 use super :: * ;
404403 use crate :: VringRwLock ;
405- use std:: io:: Error ;
406404 use std:: sync:: Mutex ;
407405 use vm_memory:: { GuestMemoryAtomic , GuestMemoryMmap } ;
408406
@@ -454,18 +452,15 @@ pub mod tests {
454452 vec ! [ 0xa5u8 ; 8 ]
455453 }
456454
457- fn set_config ( & mut self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) , Error > {
455+ fn set_config ( & mut self , offset : u32 , buf : & [ u8 ] ) -> Result < ( ) > {
458456 assert_eq ! ( offset, 0x200 ) ;
459457 assert_eq ! ( buf. len( ) , 8 ) ;
460458 assert_eq ! ( buf, & [ 0xa5u8 ; 8 ] ) ;
461459
462460 Ok ( ( ) )
463461 }
464462
465- fn update_memory (
466- & mut self ,
467- _atomic_mem : GuestMemoryAtomic < GuestMemoryMmap > ,
468- ) -> Result < ( ) , Error > {
463+ fn update_memory ( & mut self , _atomic_mem : GuestMemoryAtomic < GuestMemoryMmap > ) -> Result < ( ) > {
469464 Ok ( ( ) )
470465 }
471466
@@ -487,7 +482,7 @@ pub mod tests {
487482 _evset : EventSet ,
488483 _vrings : & [ VringRwLock ] ,
489484 _thread_id : usize ,
490- ) -> Result < bool , Error > {
485+ ) -> Result < bool > {
491486 self . events += 1 ;
492487
493488 Ok ( false )
0 commit comments