Plugin config options with no defaults

This commit is contained in:
Justin Moon
2022-07-02 00:13:49 -04:00
committed by Christian Decker
parent 76623b2ef2
commit f111d6772d
2 changed files with 32 additions and 13 deletions

View File

@@ -1,11 +1,14 @@
use serde::ser::{SerializeStruct, Serializer};
use serde::{Serialize};
use serde::Serialize;
#[derive(Clone, Debug)]
pub enum Value {
String(String),
Integer(i64),
Boolean(bool),
OptString,
OptInteger,
OptBoolean,
}
/// An stringly typed option that is passed to
@@ -45,11 +48,19 @@ impl Serialize for ConfigOption {
s.serialize_field("type", "int")?;
s.serialize_field("default", i)?;
}
Value::Boolean(b) => {
s.serialize_field("type", "bool")?;
s.serialize_field("default", b)?;
}
Value::OptString => {
s.serialize_field("type", "string")?;
}
Value::OptInteger => {
s.serialize_field("type", "int")?;
}
Value::OptBoolean => {
s.serialize_field("type", "bool")?;
}
}
s.serialize_field("description", &self.description)?;