deepr-utils 0.1.2

Utils Package for deepr SDK
Documentation
use crate::constants;
use std::fs;
use std::io::prelude::*;

#[allow(dead_code)]
#[derive(Debug)]
pub struct RuntimeOS {
    family: String,
}

impl RuntimeOS {
    pub fn new(&self) -> Self {
        if self.is_wsl() {
            Self {
                family: String::from("wsl"),
            }
        } else {
            Self {
                family: String::from(std::env::consts::OS),
            }
        }
    }

    fn is_wsl(&self) -> bool {
        let mut file = fs::File::open(constants::OS_RELEASE_PATH).expect("File not found");
        let mut data = String::new();
        file.read_to_string(&mut data)
            .expect("Error while reading file");
        data.to_lowercase().contains("wsl")
    }
}