start parsing values correctly

This commit is contained in:
nora 2024-04-14 21:46:10 +02:00
parent a7822229f3
commit 43747f9cda
5 changed files with 31 additions and 25 deletions

View file

@ -61,17 +61,20 @@ impl DataSource for ExampleDataSource {
}
fn read(&self, config: Value) -> DResult<Value> {
let name = match config {
Value::Known(ValueKind::Object(mut obj)) => obj.remove("name").unwrap(),
_ => unreachable!(),
};
let name_str = match &name {
Value::Known(ValueKind::String(s)) => s.clone(),
_ => unreachable!(),
};
Ok(Value::Known(ValueKind::Object(BTreeMap::from([
(
"name".to_owned(),
match config {
Value::Known(ValueKind::Object(mut obj)) => obj.remove("name").unwrap(),
_ => unreachable!(),
},
),
("name".to_owned(), name),
(
"meow".to_owned(),
Value::Known(ValueKind::String("mrrrrr".to_owned())),
Value::Known(ValueKind::String(format!("mrrrrr i am {name_str}"))),
),
(
"id".to_owned(),