You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: freezer.rs
    path of file: ./repos/youki/crates/libcgroups/src/v1
    
    the code of the file until where you have to start completion: use std::io::Read;
use std::{fs::OpenOptions, path::Path, thread, time};

use crate::common::{self, WrapIoResult, WrappedIoError};
use crate::common::{ControllerOpt, FreezerState};

use super::controller::Controller;

const CGROUP_FREEZER_STATE: &str = "freezer.state";
const FREEZER_STATE_THAWED: &str = "THAWED";
const FREEZER_STATE_FROZEN: &str = "FROZEN";
const FREEZER_STATE_FREEZING: &str = "FREEZING";

#[derive(thiserror::Error, Debug)]
pub enum V1FreezerControllerError {
    #[error("io error: {0}")]
    WrappedIo(#[from] WrappedIo
    
    fn test_add_and_apply() {
        let tmp = tempfile::tempdir().unwrap();
        set_fixture(tmp.path(), CGROUP_FREEZER_STATE, "").expect("set fixure for freezer state");
        set_fixture(tmp.path(), CGROUP_PROCS, "").expect("set fixture for proc file");

        // set Thawed state.
        {
            let linux_resources = LinuxResourcesBuilder::default()
                .devices(vec![])
                .hugepage_limits(vec![])
                .build()
                .unwrap();
            let state = FreezerState::Thawed;

            let controller_opt = ControllerOpt {
                resources: &linux_resources,
                freezer_state: Some(state),
                oom_score_adj: None,
                disable_oom_killer: false,
            };

            let pid = Pid::from_raw(1000);
            Freezer::add_task(pid, tmp.path()).expect("freezer add task");
            <Freezer as Controller>::apply(&controller_opt, tmp.path()).expect("freezer apply");
            let state_content = std::fs::read_to_string(tmp.path().join(CGROUP_FREEZER_STATE))
                .expect("read to string");
            assert_eq!(FREEZER_STATE_THAWED, state_content);
            let pid_content =
                std::fs::read_to_string(tmp.path().join(CGROUP_PROCS)).expect("read to string");
            assert_eq!(pid_content, "1000");
        }

        // set Frozen state.
        {
            let linux_resources = LinuxResourcesBuilder::default()
                .devices(vec![])
                .hugepage_limits(vec![])
                .build()
                .unwrap();
            let state = FreezerState::Frozen;

            let controller_opt = ControllerOpt {
                resources: &linux_resources,
                freezer_state: Some(state),
                oom_score_adj: None,
                disable_oom_killer: false,
            };

            let pid = Pid::from_raw(1001);
            Freezer::add_task(pid, tmp.path()).expect("freezer add task");
            <Freezer as Controller>::apply(&controller_opt, tmp.path()).expect("freezer apply");
            let state_content = std::fs::read_to_string(tmp.path().join(CGROUP_FREEZER_STATE))
                .expect("read to string");
            assert_eq!(FREEZER_STATE_FROZEN, state_content);
            let pid_content =
                std::fs::read_to_string(tmp.path().join(CGROUP_PROCS)).expect("read to string");
            assert_eq!(pid_content, "1001");
        }

        // set Undefined state.
        {
            let linux_resources = LinuxResourcesBuilder::default()
                .devices(vec![])
                .hugepage_limits(vec![])
                .build()
                .unwrap();

            let state = FreezerState::Undefined;

            let controller_opt = ControllerOpt {
                resources: &linux_resources,
                freezer_state: Some(state),
                oom_score_adj: None,
                disable_oom_killer: false,
            };

            let pid = Pid::from_raw(1002);
            let old_state_content = std::fs::read_to_string(tmp.path().join(CGROUP_FREEZER_STATE))
                .expect("read to string");
            Freezer::add_task(pid, tmp.path()).expect("freezer add task");
            <Freezer as Controller>::apply(&controller_opt, tmp.path()).expect("freezer apply");
            let state_content = std::fs::read_to_string(tmp.path().join(CGROUP_FREEZER_STATE))
                .expect("read to string");
            assert_eq!(old_state_content, state_content);
            let pid_content =
                std::fs::read_to_string(tmp.path().join(CGROUP_PROCS)).expect("read to string");
            assert_eq!(pid_content, "1002");
        }
    }