fn rotate_output_file_to_idx(
    idx_state: IdxState,
    config: &FileLogWriterConfig,
) -> Result<IdxState, FlexiLoggerError> {
    let new_idx = match idx_state {
        IdxState::Start => 0,
        IdxState::Idx(idx) => idx + 1,
    };

    match std::fs::rename(
        get_filepath(Some(CURRENT_INFIX), &config.filename_config),
        get_filepath(Some(&number_infix(new_idx)), &config.filename_config),
    ) {
        Ok(()) => Ok(IdxState::Idx(new_idx)),
        Err(e) => {
            if e.kind() == std::io::ErrorKind::NotFound {
                // current did not exist, so we had nothing to do
                Ok(idx_state)
            } else {
                Err(FlexiLoggerError::Io(e))
            }
        }
    }
}
// Moves the current file to the name with the next rotate_idx and returns the next rotate_idx.
// The current file must be closed already.
Moves the current file to the name with the next rotate_idx and returns the next rotate_idx.
The current file must be closed already.
Moves the current file to the name with the next rotate_idx and returns the next rotate_idx . The current file must be closed already .
fn rotate_output_file_to_idx(
    idx_state: IdxState,
    config: &FileLogWriterConfig,
) -> Result<IdxState, FlexiLoggerError> {
    let new_idx = match idx_state {
        IdxState::Start => 0,
        IdxState::Idx(idx) => idx + 1,
    };
    match std::fs::rename(
        get_filepath(Some(CURRENT_INFIX), &config.filename_config),
        get_filepath(Some(&number_infix(new_idx)), &config.filename_config),
    ) {
        Ok(()) => Ok(IdxState::Idx(new_idx)),
        Err(e) => {
            if e.kind() == std::io::ErrorKind::NotFound {
                // current did not exist, so we had nothing to do
                Ok(idx_state)
            } else {
                Err(FlexiLoggerError::Io(e))
            }
        }
    }
}
fn rotate_output_file_to_idx ( idx_state : IdxState , config : & FileLogWriterConfig , ) -> Result < IdxState , FlexiLoggerError > { let new_idx = match idx_state { IdxState :: Start => 0 , IdxState :: Idx ( idx ) => idx + 1 , } ; match std :: fs :: rename ( get_filepath ( Some ( CURRENT_INFIX ) , & config . filename_config ) , get_filepath ( Some ( & number_infix ( new_idx ) ) , & config . filename_config ) , ) { Ok ( ( ) ) => Ok ( IdxState :: Idx ( new_idx ) ) , Err ( e ) => { if e . kind ( ) == std :: io :: ErrorKind :: NotFound { // current did not exist, so we had nothing to do Ok ( idx_state ) } else { Err ( FlexiLoggerError :: Io ( e ) ) } } } }
Moves the current file to the name with the next rotate_idx and returns the next rotate_idx.
Moves the current file to the name with the next rotate_idx and returns the next rotate_idx .
idx_state
IdxState
config
&FileLogWriterConfig
idx_state
IdxState
config
&FileLogWriterConfig