impl ButtonName.resolve_name

This commit is contained in:
Akulij 2025-05-23 15:49:30 +05:00
parent 99758500b3
commit 1117af0724

View File

@ -388,6 +388,24 @@ pub enum ButtonName {
Literal { literal: String }, Literal { literal: String },
} }
impl ButtonName {
pub async fn resolve_name(self, db: &mut DB) -> ScriptResult<String> {
match self {
ButtonName::Value { name } => Ok(name),
ButtonName::Literal { literal } => {
let value = db.get_literal_value(&literal).await?;
Ok(match value {
Some(value) => Ok(value),
None => Err(ResolveError::IncorrectLiteral(format!(
"not found literal `{literal}` in DB"
))),
}?)
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Button { pub struct Button {
name: String, name: String,