Make types private to crate

These are binary crates and their types aren't required to be exposed
out of the crates. Make them private to the crate.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
Viresh Kumar 2022-10-11 15:37:19 +05:30
parent d6f3a9e146
commit 1fb0e441a7
6 changed files with 21 additions and 21 deletions

View File

@ -23,7 +23,7 @@ pub(crate) type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Eq, PartialEq, ThisError)]
/// Errors related to low level GPIO helpers
pub enum Error {
pub(crate) enum Error {
#[error("Invalid socket count: {0}")]
SocketCountInvalid(usize),
#[error("Socket count ({0}) doesn't match device count {1}")]

View File

@ -27,7 +27,7 @@ type Result<T> = std::result::Result<T, Error>;
#[derive(Copy, Clone, Debug, PartialEq, ThisError)]
/// Errors related to low level i2c helpers
pub enum Error {
pub(crate) enum Error {
#[error("Incorrect message length for {0} operation: {1}")]
MessageLengthInvalid(&'static str, usize),
#[error("Invalid SMBUS command: {0}")]
@ -74,7 +74,7 @@ const I2C_FUNC_SMBUS_ALL: u64 =
I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA;
/// I2C protocol definitions
pub const I2C_M_RD: u16 = 0x0001; // read data, from slave to master
pub(crate) const I2C_M_RD: u16 = 0x0001; // read data, from slave to master
/// Copied (partially) from Linux's include/uapi/linux/i2c.h
///
@ -115,7 +115,7 @@ struct I2cMsg {
/// This is the structure as used in the I2C_RDWR ioctl call
#[repr(C)]
pub struct I2cRdwrIoctlData {
pub(crate) struct I2cRdwrIoctlData {
msgs: *mut I2cMsg,
nmsgs: u32,
}
@ -157,14 +157,14 @@ impl I2cSmbusData {
/// This is the structure as used in the I2C_SMBUS ioctl call
#[repr(C)]
pub struct I2cSmbusIoctlData {
pub(crate) struct I2cSmbusIoctlData {
read_write: u8,
command: u8,
size: u32,
data: *mut I2cSmbusData,
}
pub struct SmbusMsg {
pub(crate) struct SmbusMsg {
read_write: u8,
command: u8,
size: u32,
@ -284,7 +284,7 @@ impl SmbusMsg {
}
/// I2C definitions
pub struct I2cReq {
pub(crate) struct I2cReq {
pub addr: u16,
pub flags: u16,
pub len: u16,
@ -297,7 +297,7 @@ pub struct I2cReq {
/// be used outside of this crate. The purpose of this trait is to provide a
/// mock implementation for the I2C driver so that we can test the I2C
/// functionality without the need of a physical device.
pub trait I2cDevice {
pub(crate) trait I2cDevice {
// Open the device specified by the adapter number.
fn open(device_path: &str, adapter_no: u32) -> Result<Self>
where
@ -322,7 +322,7 @@ pub trait I2cDevice {
/// A physical I2C device. This structure can only be initialized on hosts
/// where `/dev/i2c-XX` is available.
#[derive(Debug)]
pub struct PhysDevice {
pub(crate) struct PhysDevice {
file: File,
adapter_no: u32,
}
@ -425,7 +425,7 @@ impl I2cDevice for PhysDevice {
}
#[derive(Debug)]
pub struct I2cAdapter<D: I2cDevice> {
pub(crate) struct I2cAdapter<D: I2cDevice> {
device: D,
adapter_no: u32,
smbus: bool,
@ -507,7 +507,7 @@ impl<D: I2cDevice> I2cAdapter<D> {
/// I2C map and helpers
pub(crate) const MAX_I2C_VDEV: usize = 1 << 7;
pub struct I2cMap<D: I2cDevice> {
pub(crate) struct I2cMap<D: I2cDevice> {
adapters: Vec<I2cAdapter<D>>,
device_map: HashMap<u16, usize>,
}
@ -569,7 +569,7 @@ impl<D: I2cDevice> I2cMap<D> {
}
#[cfg(test)]
pub mod tests {
pub(crate) mod tests {
use super::*;
use vmm_sys_util::tempfile::TempFile;

View File

@ -26,7 +26,7 @@ type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, PartialEq, ThisError)]
/// Errors related to low level i2c helpers
pub enum Error {
pub(crate) enum Error {
#[error("Invalid socket count: {0}")]
SocketCountInvalid(usize),
#[error("Invalid device list")]

View File

@ -38,7 +38,7 @@ type VhostUserBackendResult<T> = std::result::Result<T, std::io::Error>;
#[derive(Copy, Clone, Debug, Eq, PartialEq, ThisError)]
/// Errors related to vhost-device-i2c daemon.
pub enum Error {
pub(crate) enum Error {
#[error("Failed to handle event, didn't match EPOLLIN")]
HandleEventNotEpollIn,
#[error("Failed to handle unknown event")]
@ -94,7 +94,7 @@ struct VirtioI2cInHdr {
}
unsafe impl ByteValued for VirtioI2cInHdr {}
pub struct VhostUserI2cBackend<D: I2cDevice> {
pub(crate) struct VhostUserI2cBackend<D: I2cDevice> {
i2c_map: Arc<I2cMap<D>>,
event_idx: bool,
pub exit_event: EventFd,

View File

@ -26,7 +26,7 @@ type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Eq, PartialEq, ThisError)]
/// Errors related to vhost-device-rng daemon.
pub enum Error {
pub(crate) enum Error {
#[error("RNG source file doesn't exists or can't be accessed")]
AccessRngSourceFile,
#[error("Period is too big: {0}")]
@ -62,7 +62,7 @@ struct RngArgs {
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct VuRngConfig {
pub(crate) struct VuRngConfig {
pub period_ms: u128,
pub max_bytes: usize,
pub count: u32,
@ -98,7 +98,7 @@ impl TryFrom<RngArgs> for VuRngConfig {
}
}
pub fn start_backend(config: VuRngConfig) -> Result<()> {
pub(crate) fn start_backend(config: VuRngConfig) -> Result<()> {
let mut handles = Vec::new();
let file = File::open(&config.rng_source).map_err(|_| Error::AccessRngSourceFile)?;
let random_file = Arc::new(Mutex::new(file));

View File

@ -34,7 +34,7 @@ type RngDescriptorChain = DescriptorChain<GuestMemoryLoadGuard<GuestMemoryMmap<(
#[derive(Debug, Eq, PartialEq, ThisError)]
/// Errors related to vhost-device-rng daemon.
pub enum VuRngError {
pub(crate) enum VuRngError {
#[error("Descriptor not found")]
DescriptorNotFound,
#[error("Notification send failed")]
@ -66,7 +66,7 @@ impl convert::From<VuRngError> for io::Error {
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct VuRngTimerConfig {
pub(crate) struct VuRngTimerConfig {
period_ms: u128,
period_start: Instant,
max_bytes: usize,
@ -84,7 +84,7 @@ impl VuRngTimerConfig {
}
}
pub struct VuRngBackend<T: Read> {
pub(crate) struct VuRngBackend<T: Read> {
event_idx: bool,
timer: VuRngTimerConfig,
rng_source: Arc<Mutex<T>>,