pub fn new_cgroup(
        &mut self,
        file: String,
        value: String,
        id: &str,
        exec_file_name: &OsStr,
    ) -> Result<Box<dyn Cgroup>> {
        match self.version {
            1 => {
                let controller = get_controller_from_filename(&file)?;
                let path = self.get_v1_hierarchy_path(&controller)?;

                let cgroup = CgroupV1::new(file, value, id, &exec_file_name, &path)?;
                Ok(Box::new(cgroup))
            }
            2 => {
                // since all cgroups are unified for v2 and the path was discovered when
                // the builder was constructed, we try and get it right away
                let path = self
                    .hierarchies
                    .get("unified")
                    .ok_or_else(|| Error::CgroupHierarchyMissing("unified".to_string()))?;

                let cgroup = CgroupV2::new(file, value, id, &exec_file_name, &path)?;
                Ok(Box::new(cgroup))
            }
            _ => Err(Error::CgroupInvalidVersion(self.version.to_string())),
        }
    }
// Creates a new cggroup and returns it
Creates a new cggroup and returns it
Creates a new cggroup and returns it
pub fn new_cgroup(
        &mut self,
        file: String,
        value: String,
        id: &str,
        exec_file_name: &OsStr,
    ) -> Result<Box<dyn Cgroup>> {
        match self.version {
            1 => {
                let controller = get_controller_from_filename(&file)?;
                let path = self.get_v1_hierarchy_path(&controller)?;
                let cgroup = CgroupV1::new(file, value, id, &exec_file_name, &path)?;
                Ok(Box::new(cgroup))
            }
            2 => {
                // since all cgroups are unified for v2 and the path was discovered when
                // the builder was constructed, we try and get it right away
                let path = self
                    .hierarchies
                    .get("unified")
                    .ok_or_else(|| Error::CgroupHierarchyMissing("unified".to_string()))?;
                let cgroup = CgroupV2::new(file, value, id, &exec_file_name, &path)?;
                Ok(Box::new(cgroup))
            }
            _ => Err(Error::CgroupInvalidVersion(self.version.to_string())),
        }
    }
pub fn new_cgroup ( & mut self , file : String , value : String , id : & str , exec_file_name : & OsStr , ) -> Result < Box < dyn Cgroup > > { match self . version { 1 => { let controller = get_controller_from_filename ( & file ) ? ; let path = self . get_v1_hierarchy_path ( & controller ) ? ; let cgroup = CgroupV1 :: new ( file , value , id , & exec_file_name , & path ) ? ; Ok ( Box :: new ( cgroup ) ) } 2 => { // since all cgroups are unified for v2 and the path was discovered when // the builder was constructed, we try and get it right away let path = self . hierarchies . get ( " " ) . ok_or_else ( | | Error :: CgroupHierarchyMissing ( " " . to_string ( ) ) ) ? ; let cgroup = CgroupV2 :: new ( file , value , id , & exec_file_name , & path ) ? ; Ok ( Box :: new ( cgroup ) ) } _ => Err ( Error :: CgroupInvalidVersion ( self . version . to_string ( ) ) ) , } }
Creates a new cggroup and returns it
Creates a new cggroup and returns it
&mut self
file
String
value
String
id
&str
exec_file_name
&OsStr
&mut self
file
String
value
String
id
&str
exec_file_name
&OsStr