thot-local 0.10.0-intermediate

Local functionality for Thot data management and analysis software.
Documentation
use serde::{Serialize, Deserialize};
use std::cmp::PartialEq;


// ************************
// *** User Preferences ***
// ************************

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct UserPreferences {
    general: GeneralUserPreferences,
    project: ProjectUserPreferences,
    analysis: AnalysisUserPreferences,
}

impl UserPreferences {
    pub fn new() -> Self {
        UserPreferences {
            general: GeneralUserPreferences::new(),
            project: ProjectUserPreferences::new(),
            analysis: AnalysisUserPreferences:: new(),
        }
    }
}

// ********************************
// *** General User Preferences ***
// ********************************

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct GeneralUserPreferences {
    open_previous_project_on_start: bool,
}

impl GeneralUserPreferences {
    pub fn new() -> Self {
        GeneralUserPreferences {
            open_previous_project_on_start: true,
        }
    }
}

// ********************************
// *** Project User Preferences ***
// ********************************

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ProjectUserPreferences {
    asset_file_action: AssetFileAction,  // how asset files should be manipulated when changed into an asset
    rename_folder_on_name_change: bool,  // rename container flder when name is changed
    delete_on_exclude: bool,  // delete folder and files when a subtree is excluded
    format_metdata_objects: bool,  // pretty print and validate metadata objects in the editor
    show_inherited_metadata: bool,  // show inherited metadata when viewing object details
}

impl ProjectUserPreferences {
    /// Create a new project preferences with default values.
    ///
    /// + **asset_file_action:** AssetFileAction::Move
    /// + **rename_folder_on_name_change:** true
    /// + **delete_on_exclude:** false
    /// + **format_metdata_objects:** true
    /// + **show_inherited_metadata:** false
    pub fn new() -> Self {
        ProjectUserPreferences {
            asset_file_action: AssetFileAction::Move,
            rename_folder_on_name_change: true,
            delete_on_exclude: false,
            format_metdata_objects: true,
            show_inherited_metadata: false,
        }
    }
}


// ***********************
// *** Asset File Action ***
// ***********************

/// How an Asset's file should be handled when created.
///
/// + **Move:** Move original asset file to new location.
/// + **Copy:** Copy asset file into location, leaving original in place.
/// + **Reference:** Reference original asset file, do not move.
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
pub enum AssetFileAction {
    Move,
    Copy,
    Reference,
}

// *********************************
// *** Analysis User Preferences ***
// *********************************

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AnalysisUserPreferences {
    
}

impl AnalysisUserPreferences {
    pub fn new() -> Self {
        AnalysisUserPreferences {}
    }
}


#[cfg(test)]
#[path = "./user_preferences_test.rs"]
mod user_preferences_test;