/// Create a new counter service with the given file as the backing file.
Create a new counter service with the given file as the backing file.
Create a new counter service with the given file as the backing file .
pub fn new<P>(file_path: P) -> Self
    where
        P: Into<PathBuf>,
    {
        let path = file_path.into();
        let init_counter: u64 = {
            match std::fs::read_to_string(&path) {
                Ok(s) => match s.parse() {
                    Ok(n) => n,
                    Err(e) => {
                        log::warn!("Failed to parse meow counter: {}", e);
                        0
                    }
                },
                Err(e) => {
                    log::warn!("Failed to read meow counter from file: {}", e);
                    0
                }
            }
        };
        Self {
            path,
            counter: AtomicU64::new(init_counter),
            write_file_lock: Mutex::new(()),
        }
    }
pub fn new < P > ( file_path : P ) -> Self where P : Into < PathBuf > , { let path = file_path . into ( ) ; let init_counter : u64 = { match std :: fs :: read_to_string ( & path ) { Ok ( s ) => match s . parse ( ) { Ok ( n ) => n , Err ( e ) => { log :: warn ! ( " " e ) ; 0 } } , Err ( e ) => { log :: warn ! ( " " e ) ; 0 } } } ; Self { path , counter : AtomicU64 :: new ( init_counter ) , write_file_lock : Mutex :: new ( ( ) ) , } }
Create a new counter service with the given file as the backing file.
Create a new counter service with the given file as the backing file .
file_path
P