diff --git a/src/blkio.rs b/src/blkio.rs index 1fded4c..fa55f64 100644 --- a/src/blkio.rs +++ b/src/blkio.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ BlkIoResources, ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem, }; @@ -48,7 +48,7 @@ pub struct IoService { /// How many items were synchronously transferred. pub sync: u64, /// How many items were asynchronously transferred. - pub async: u64, + pub r#async: u64, /// Total number of items transferred. pub total: u64, } @@ -77,7 +77,7 @@ fn parse_io_service(s: String) -> Result> { read: read_val.parse::().unwrap(), write: write_val.parse::().unwrap(), sync: sync_val.parse::().unwrap(), - async: async_val.parse::().unwrap(), + r#async: async_val.parse::().unwrap(), total: total_val.parse::().unwrap(), }), _ => None, @@ -695,9 +695,9 @@ impl BlkIoController { #[cfg(test)] mod test { - use blkio::{parse_blkio_data, BlkIoData}; - use blkio::{parse_io_service, parse_io_service_total, IoService}; - use error::*; + use crate::blkio::{parse_blkio_data, BlkIoData}; + use crate::blkio::{parse_io_service, parse_io_service_total, IoService}; + use crate::error::*; static TEST_VALUE: &str = "\ 8:32 Read 4280320 @@ -773,7 +773,7 @@ Total 61823067136 read: 4280320, write: 0, sync: 4280320, - async: 0, + r#async: 0, total: 4280320, }, IoService { @@ -782,7 +782,7 @@ Total 61823067136 read: 5705479168, write: 56096055296, sync: 11213923328, - async: 50587611136, + r#async: 50587611136, total: 61801534464, }, IoService { @@ -791,7 +791,7 @@ Total 61823067136 read: 10059776, write: 0, sync: 10059776, - async: 0, + r#async: 0, total: 10059776, }, IoService { @@ -800,7 +800,7 @@ Total 61823067136 read: 7192576, write: 0, sync: 7192576, - async: 0, + r#async: 0, total: 7192576, } ] diff --git a/src/cgroup.rs b/src/cgroup.rs index 9fae5ca..140a4f4 100644 --- a/src/cgroup.rs +++ b/src/cgroup.rs @@ -1,8 +1,8 @@ //! This module handles cgroup operations. Start here! -use error::*; +use crate::error::*; -use {CgroupPid, ControllIdentifier, Controller, Hierarchy, Resources, Subsystem}; +use crate::{CgroupPid, ControllIdentifier, Controller, Hierarchy, Resources, Subsystem}; use std::convert::From; use std::path::Path; diff --git a/src/cgroup_builder.rs b/src/cgroup_builder.rs index dbf8c30..31999c8 100644 --- a/src/cgroup_builder.rs +++ b/src/cgroup_builder.rs @@ -53,9 +53,9 @@ //! .done() //! .build(); //! ``` -use error::*; +use crate::error::*; -use {pid, BlkIoDeviceResource, BlkIoDeviceThrottleResource, Cgroup, DeviceResource, Hierarchy, HugePageResource, NetworkPriority, Resources}; +use crate::{pid, BlkIoDeviceResource, BlkIoDeviceThrottleResource, Cgroup, DeviceResource, Hierarchy, HugePageResource, NetworkPriority, Resources}; macro_rules! gen_setter { ($res:ident, $cont:ident, $func:ident, $name:ident, $ty:ty) => { @@ -215,9 +215,9 @@ impl<'a> DeviceResourceBuilder<'a> { pub fn device(mut self, major: i64, minor: i64, - devtype: ::devices::DeviceType, + devtype: crate::devices::DeviceType, allow: bool, - access: Vec<::devices::DevicePermissions>) + access: Vec) -> DeviceResourceBuilder<'a> { self.cgroup.resources.devices.update_values = true; self.cgroup.resources.devices.devices.push(DeviceResource { diff --git a/src/cpu.rs b/src/cpu.rs index de123fb..3e43ea8 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -7,10 +7,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, CpuResources, Resources, Subsystem, }; diff --git a/src/cpuacct.rs b/src/cpuacct.rs index 687ad13..ec3b967 100644 --- a/src/cpuacct.rs +++ b/src/cpuacct.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use {ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; +use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; /// A controller that allows controlling the `cpuacct` subsystem of a Cgroup. /// diff --git a/src/cpuset.rs b/src/cpuset.rs index 1d0ed45..b7b679a 100644 --- a/src/cpuset.rs +++ b/src/cpuset.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, CpuResources, Resources, Subsystem, }; @@ -427,7 +427,7 @@ impl CpuSetController { #[cfg(test)] mod tests { - use cpuset; + use crate::cpuset; #[test] fn test_parse_range() { let test_cases = vec![ diff --git a/src/devices.rs b/src/devices.rs index e3371f8..cee0157 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -5,10 +5,10 @@ use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, DeviceResource, DeviceResources, Resources, Subsystem, }; diff --git a/src/freezer.rs b/src/freezer.rs index a4d8275..632ee27 100644 --- a/src/freezer.rs +++ b/src/freezer.rs @@ -5,10 +5,10 @@ use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use {ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; +use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; /// A controller that allows controlling the `freezer` subsystem of a Cgroup. /// diff --git a/src/hierarchies.rs b/src/hierarchies.rs index 4db60c6..920211f 100644 --- a/src/hierarchies.rs +++ b/src/hierarchies.rs @@ -8,22 +8,22 @@ use std::io::BufRead; use std::io::BufReader; use std::path::{Path, PathBuf}; -use blkio::BlkIoController; -use cpu::CpuController; -use cpuacct::CpuAcctController; -use cpuset::CpuSetController; -use devices::DevicesController; -use freezer::FreezerController; -use hugetlb::HugeTlbController; -use memory::MemController; -use net_cls::NetClsController; -use net_prio::NetPrioController; -use perf_event::PerfEventController; -use pid::PidController; -use rdma::RdmaController; -use {Controllers, Hierarchy, Subsystem}; +use crate::blkio::BlkIoController; +use crate::cpu::CpuController; +use crate::cpuacct::CpuAcctController; +use crate::cpuset::CpuSetController; +use crate::devices::DevicesController; +use crate::freezer::FreezerController; +use crate::hugetlb::HugeTlbController; +use crate::memory::MemController; +use crate::net_cls::NetClsController; +use crate::net_prio::NetPrioController; +use crate::perf_event::PerfEventController; +use crate::pid::PidController; +use crate::rdma::RdmaController; +use crate::{Controllers, Hierarchy, Subsystem}; -use cgroup::Cgroup; +use crate::cgroup::Cgroup; /// The standard, original cgroup implementation. Often referred to as "cgroupv1". pub struct V1 { diff --git a/src/hugetlb.rs b/src/hugetlb.rs index db714d1..5c3b1b7 100644 --- a/src/hugetlb.rs +++ b/src/hugetlb.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, HugePageResources, Resources, Subsystem, }; diff --git a/src/lib.rs b/src/lib.rs index 5983bf5..27419ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,22 +23,22 @@ pub mod pid; pub mod rdma; pub mod cgroup_builder; -use blkio::BlkIoController; -use cpu::CpuController; -use cpuacct::CpuAcctController; -use cpuset::CpuSetController; -use devices::DevicesController; -use error::*; -use freezer::FreezerController; -use hugetlb::HugeTlbController; -use memory::MemController; -use net_cls::NetClsController; -use net_prio::NetPrioController; -use perf_event::PerfEventController; -use pid::PidController; -use rdma::RdmaController; +use crate::blkio::BlkIoController; +use crate::cpu::CpuController; +use crate::cpuacct::CpuAcctController; +use crate::cpuset::CpuSetController; +use crate::devices::DevicesController; +use crate::error::*; +use crate::freezer::FreezerController; +use crate::hugetlb::HugeTlbController; +use crate::memory::MemController; +use crate::net_cls::NetClsController; +use crate::net_prio::NetPrioController; +use crate::perf_event::PerfEventController; +use crate::pid::PidController; +use crate::rdma::RdmaController; -pub use cgroup::Cgroup; +pub use crate::cgroup::Cgroup; /// Contains all the subsystems that are available in this crate. #[derive(Debug)] @@ -160,7 +160,7 @@ mod sealed { } } -pub(crate) use sealed::ControllerInternal; +pub(crate) use crate::sealed::ControllerInternal; /// A Controller is a subsystem attached to the control group. /// @@ -347,13 +347,13 @@ pub struct DeviceResource { /// If true, access to the device is allowed, otherwise it's denied. pub allow: bool, /// `'c'` for character device, `'b'` for block device; or `'a'` for all devices. - pub devtype: ::devices::DeviceType, + pub devtype: crate::devices::DeviceType, /// The major number of the device. pub major: i64, /// The minor number of the device. pub minor: i64, /// Sequence of `'r'`, `'w'` or `'m'`, each denoting read, write or mknod permissions. - pub access: Vec<::devices::DevicePermissions>, + pub access: Vec, } /// Limit the usage of devices for the control group's tasks. diff --git a/src/memory.rs b/src/memory.rs index 7c54ebf..d7acaf8 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, MemoryResources, Resources, Subsystem, }; @@ -85,7 +85,7 @@ pub struct NumaStat { fn parse_numa_stat(s: String) -> Result { // Parse the number of nodes - let nodes = (s.split_whitespace().collect::>().len() - 8) / 8; + let _nodes = (s.split_whitespace().collect::>().len() - 8) / 8; let mut ls = s.lines(); let total_line = ls.next().unwrap(); let file_line = ls.next().unwrap(); @@ -697,7 +697,7 @@ fn read_string_from(mut file: File) -> Result { #[cfg(test)] mod tests { - use memory::{ + use crate::memory::{ parse_memory_stat, parse_numa_stat, parse_oom_control, MemoryStat, NumaStat, OomControl, }; diff --git a/src/net_cls.rs b/src/net_cls.rs index c3e7e9e..c3057f9 100644 --- a/src/net_cls.rs +++ b/src/net_cls.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, NetworkResources, Resources, Subsystem, }; diff --git a/src/net_prio.rs b/src/net_prio.rs index 9fcb428..6c2ed7b 100644 --- a/src/net_prio.rs +++ b/src/net_prio.rs @@ -7,10 +7,10 @@ use std::fs::File; use std::io::{BufRead, BufReader, Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, NetworkResources, Resources, Subsystem, }; diff --git a/src/perf_event.rs b/src/perf_event.rs index 9f930c5..4f52b1b 100644 --- a/src/perf_event.rs +++ b/src/perf_event.rs @@ -4,9 +4,9 @@ //! [tools/perf/Documentation/perf-record.txt](https://raw.githubusercontent.com/torvalds/linux/master/tools/perf/Documentation/perf-record.txt) use std::path::PathBuf; -use error::*; +use crate::error::*; -use {ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; +use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; /// A controller that allows controlling the `perf_event` subsystem of a Cgroup. /// diff --git a/src/pid.rs b/src/pid.rs index 3cff49b..d7f42d2 100644 --- a/src/pid.rs +++ b/src/pid.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use { +use crate::{ ControllIdentifier, ControllerInternal, Controllers, PidResources, Resources, Subsystem, }; diff --git a/src/rdma.rs b/src/rdma.rs index ea4b078..fb9dcc6 100644 --- a/src/rdma.rs +++ b/src/rdma.rs @@ -6,10 +6,10 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; -use error::*; -use error::ErrorKind::*; +use crate::error::*; +use crate::error::ErrorKind::*; -use {ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; +use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem}; /// A controller that allows controlling the `rdma` subsystem of a Cgroup. /// diff --git a/tests/builder.rs b/tests/builder.rs index c19fd31..691f535 100644 --- a/tests/builder.rs +++ b/tests/builder.rs @@ -12,7 +12,7 @@ use cgroups::cgroup_builder::*; #[test] pub fn test_cpu_res_build() { - let v1 = ::hierarchies::V1::new(); + let v1 = crate::hierarchies::V1::new(); let cg: Cgroup = CgroupBuilder::new("test_cpu_res_build", &v1) .cpu() .shares(85) @@ -30,7 +30,7 @@ pub fn test_cpu_res_build() { #[test] pub fn test_memory_res_build() { - let v1 = ::hierarchies::V1::new(); + let v1 = crate::hierarchies::V1::new(); let cg: Cgroup = CgroupBuilder::new("test_memory_res_build", &v1) .memory() .kernel_memory_limit(128 * 1024 * 1024) @@ -51,7 +51,7 @@ pub fn test_memory_res_build() { #[test] pub fn test_pid_res_build() { - let v1 = ::hierarchies::V1::new(); + let v1 = crate::hierarchies::V1::new(); let cg: Cgroup = CgroupBuilder::new("test_pid_res_build", &v1) .pid() .maximum_number_of_processes(PidMax::Value(123)) @@ -70,7 +70,7 @@ pub fn test_pid_res_build() { #[test] #[ignore] // ignore this test for now, not sure why my kernel doesn't like it pub fn test_devices_res_build() { - let v1 = ::hierarchies::V1::new(); + let v1 = crate::hierarchies::V1::new(); let cg: Cgroup = CgroupBuilder::new("test_devices_res_build", &v1) .devices() .device(1, 6, DeviceType::Char, true, @@ -96,7 +96,7 @@ pub fn test_devices_res_build() { #[test] pub fn test_network_res_build() { - let v1 = ::hierarchies::V1::new(); + let v1 = crate::hierarchies::V1::new(); let cg: Cgroup = CgroupBuilder::new("test_network_res_build", &v1) .network() .class_id(1337) @@ -113,7 +113,7 @@ pub fn test_network_res_build() { #[test] pub fn test_hugepages_res_build() { - let v1 = ::hierarchies::V1::new(); + let v1 = crate::hierarchies::V1::new(); let cg: Cgroup = CgroupBuilder::new("test_hugepages_res_build", &v1) .hugepages() .limit("2MB".to_string(), 4 * 2 * 1024 * 1024) @@ -130,7 +130,7 @@ pub fn test_hugepages_res_build() { #[test] pub fn test_blkio_res_build() { - let v1 = ::hierarchies::V1::new(); + let v1 = crate::hierarchies::V1::new(); let cg: Cgroup = CgroupBuilder::new("test_blkio_res_build", &v1) .blkio() .weight(100)