thot-local 0.10.0-intermediate

Local functionality for Thot data management and analysis software.
Documentation
use crate::result::Result;
use crate::system::settings::user_settings::UserSettings;
use settings_manager::prelude::SystemSettings;
use thot_core::project::StandardProperties;
use thot_core::types::{Creator, UserId};

pub struct LocalStandardProperties;

impl LocalStandardProperties {
    /// Creates a new [`StandardProperties`] with fields actively filled from system settings.
    pub fn new() -> Result<StandardProperties> {
        let settings = UserSettings::load()?;
        let creator = match settings.active_user {
            Some(uid) => Some(UserId::Id(uid)),
            None => None,
        };

        let creator = Creator::User(creator);
        let mut props = StandardProperties::new();
        props.creator = creator;

        Ok(props)
    }
}

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