2022-01-14 08:31:14 +00:00
|
|
|
use crate::ctx::Context;
|
|
|
|
use crate::sql::value::Value;
|
2022-06-20 01:13:28 +00:00
|
|
|
use std::collections::BTreeMap;
|
2022-01-14 08:31:14 +00:00
|
|
|
|
2022-06-20 01:13:28 +00:00
|
|
|
pub type Variables = Option<BTreeMap<String, Value>>;
|
2022-01-14 08:31:14 +00:00
|
|
|
|
|
|
|
pub(crate) trait Attach {
|
2022-05-03 20:20:36 +00:00
|
|
|
fn attach(self, ctx: Context) -> Context;
|
2022-01-14 08:31:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Attach for Variables {
|
2022-05-03 20:20:36 +00:00
|
|
|
fn attach(self, mut ctx: Context) -> Context {
|
2022-01-14 08:31:14 +00:00
|
|
|
match self {
|
|
|
|
Some(m) => {
|
|
|
|
for (key, val) in m {
|
|
|
|
ctx.add_value(key, val);
|
|
|
|
}
|
2022-05-03 20:20:36 +00:00
|
|
|
ctx
|
2022-01-14 08:31:14 +00:00
|
|
|
}
|
|
|
|
None => ctx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|