impl ButtonName.resolve_name
This commit is contained in:
parent
99758500b3
commit
1117af0724
@ -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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user