mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2026-01-06 01:49:18 +00:00
Having all the workspace crates under the crates/ directory is unnecessary. Rust documentation itself recommends all crates to be in the root directory: https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html#creating-the-second-package-in-the-workspace I paste the text content here, in case the online page ever changes or becomes unavailable: ## Creating the Second Package in the Workspace Next, let’s create another member package in the workspace and call it add_one. Change the top-level Cargo.toml to specify the add_one path in the members list: Filename: Cargo.toml [workspace] members = [ "adder", "add_one", ] Then generate a new library crate named add_one: $ cargo new add_one --lib Created library `add_one` package Your add directory should now have these directories and files: ├── Cargo.lock ├── Cargo.toml ├── add_one │ ├── Cargo.toml │ └── src │ └── lib.rs ├── adder │ ├── Cargo.toml │ └── src │ └── main.rs └── target Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
37 lines
792 B
Rust
37 lines
792 B
Rust
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
|
|
|
|
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
|
pub(crate) enum RxOps {
|
|
/// VSOCK_OP_REQUEST
|
|
Request = 0,
|
|
/// VSOCK_OP_RW
|
|
Rw = 1,
|
|
/// VSOCK_OP_RESPONSE
|
|
Response = 2,
|
|
/// VSOCK_OP_CREDIT_UPDATE
|
|
CreditUpdate = 3,
|
|
/// VSOCK_OP_RST
|
|
Reset = 4,
|
|
}
|
|
|
|
impl RxOps {
|
|
/// Convert enum value into bitmask.
|
|
pub fn bitmask(self) -> u8 {
|
|
1u8 << (self as u8)
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_bitmask() {
|
|
assert_eq!(1, RxOps::Request.bitmask());
|
|
assert_eq!(2, RxOps::Rw.bitmask());
|
|
assert_eq!(4, RxOps::Response.bitmask());
|
|
assert_eq!(8, RxOps::CreditUpdate.bitmask());
|
|
assert_eq!(16, RxOps::Reset.bitmask());
|
|
}
|
|
}
|