Skip to content
This repository was archived by the owner on Oct 24, 2022. It is now read-only.

Commit 6d04368

Browse files
committed
backend: set default type for VhostUserBackend
Use () as default type for trait VhostUserBackend and VhostUserBackendMut. Signed-off-by: Liu Jiang <[email protected]>
1 parent 6b68592 commit 6d04368

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

coverage_config_x86_64.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"coverage_score": 50.8,
2+
"coverage_score": 77.4,
33
"exclude_path": "",
44
"crate_features": ""
55
}

src/backend.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use super::{Vring, GM};
3434
///
3535
/// To support multi-threading and asynchronous IO, we enforce `the Send + Sync + 'static`.
3636
/// So there's no plan for support of "Rc<T>" and "RefCell<T>".
37-
pub trait VhostUserBackend<B: Bitmap + 'static>: Send + Sync + 'static {
37+
pub trait VhostUserBackend<B: Bitmap + 'static = ()>: Send + Sync + 'static {
3838
/// Get number of queues supported.
3939
fn num_queues(&self) -> usize;
4040

@@ -113,7 +113,7 @@ pub trait VhostUserBackend<B: Bitmap + 'static>: Send + Sync + 'static {
113113
}
114114

115115
/// Trait without interior mutability for vhost user backend servers to implement concrete services.
116-
pub trait VhostUserBackendMut<B: Bitmap + 'static>: Send + Sync + 'static {
116+
pub trait VhostUserBackendMut<B: Bitmap + 'static = ()>: Send + Sync + 'static {
117117
/// Get number of queues supported.
118118
fn num_queues(&self) -> usize;
119119

@@ -486,7 +486,7 @@ pub mod tests {
486486
assert_eq!(backend.queues_per_thread(), [1, 1]);
487487

488488
assert_eq!(backend.get_config(0x200, 8), vec![0xa5; 8]);
489-
backend.set_config(0x200, &vec![0xa5; 8]).unwrap();
489+
backend.set_config(0x200, &[0xa5; 8]).unwrap();
490490

491491
backend.acked_features(0xffff);
492492
assert_eq!(backend.lock().unwrap().acked_features, 0xffff);
@@ -509,7 +509,7 @@ pub mod tests {
509509
assert_eq!(backend.queues_per_thread(), [1, 1]);
510510

511511
assert_eq!(backend.get_config(0x200, 8), vec![0xa5; 8]);
512-
backend.set_config(0x200, &vec![0xa5; 8]).unwrap();
512+
backend.set_config(0x200, &[0xa5; 8]).unwrap();
513513

514514
backend.acked_features(0xffff);
515515
assert_eq!(backend.read().unwrap().acked_features, 0xffff);

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub type Result<T> = result::Result<T, Error>;
7575
///
7676
/// This structure is the public API the backend is allowed to interact with in order to run
7777
/// a fully functional vhost-user daemon.
78-
pub struct VhostUserDaemon<S: VhostUserBackend<B>, B: Bitmap + 'static> {
78+
pub struct VhostUserDaemon<S: VhostUserBackend<B>, B: Bitmap + 'static = ()> {
7979
name: String,
8080
handler: Arc<Mutex<VhostUserHandler<S, B>>>,
8181
main_thread: Option<thread::JoinHandle<Result<()>>>,

0 commit comments

Comments
 (0)