use crate::{
dto::state::{AppCommand, AppStateInput, AppStateResponse},
ops::storage::state::app::AppStateCommand,
storage::stable::state::app::AppStateRecord,
};
pub struct AppStateMapper;
impl AppStateMapper {
#[must_use]
pub const fn record_to_input(data: AppStateRecord) -> AppStateInput {
AppStateInput {
mode: data.mode,
cycles_funding_enabled: data.cycles_funding_enabled,
}
}
#[must_use]
pub const fn record_to_response(data: AppStateRecord) -> AppStateResponse {
AppStateResponse {
mode: data.mode,
cycles_funding_enabled: data.cycles_funding_enabled,
}
}
#[must_use]
pub const fn input_to_record(view: AppStateInput) -> AppStateRecord {
AppStateRecord {
mode: view.mode,
cycles_funding_enabled: view.cycles_funding_enabled,
}
}
}
pub struct AppStateCommandMapper;
impl AppStateCommandMapper {
#[must_use]
pub const fn dto_to_record(cmd: AppCommand) -> AppStateCommand {
match cmd {
AppCommand::SetStatus(status) => AppStateCommand::SetStatus(status),
AppCommand::SetCyclesFundingEnabled(enabled) => {
AppStateCommand::SetCyclesFundingEnabled(enabled)
}
}
}
}