/* Copyright 2024, Savanni D'Gerinel This file is part of On the Grid. On the Grid is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. On the Grid is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with On the Grid. If not, see . */ use crate::{types::LibraryPath, Core, Config}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Serialize, Deserialize)] pub enum SettingsRequest { Get, Set(Config), } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SettingsResponse(pub Config); pub async fn handle(model: &Core, request: SettingsRequest) -> SettingsResponse { match request { SettingsRequest::Get => SettingsResponse(model.get_config()), SettingsRequest::Set(config) => { model.set_config(config).await; SettingsResponse(model.get_config()) } } }