Skip to content

Commit

Permalink
Rename OptionValue to OptionType
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikDeSmedt committed Feb 5, 2024
1 parent 9029faf commit 320dd93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions plugins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
extern crate log;
use log::trace;
use messages::{Configuration, FeatureBits, NotificationTopic};
use options::{OptionValue, UntypedConfigOption};
use options::{ConfigOptionType, UntypedConfigOption};
use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
Expand Down Expand Up @@ -136,7 +136,7 @@ where
}
}

pub fn option<V: options::OptionValue>(
pub fn option<V: options::ConfigOptionType>(
mut self,
opt: options::ConfigOption<V>,
) -> Builder<S, I, O> {
Expand Down Expand Up @@ -514,7 +514,7 @@ where
.map(|c| c.clone())
}

pub fn option<OV: OptionValue>(
pub fn option<OV: ConfigOptionType>(
&self,
config_option: &options::ConfigOption<OV>,
) -> Result<OV::OutputValue> {
Expand Down Expand Up @@ -611,7 +611,7 @@ where
.map(|c| c.clone())
}

pub fn option<OV: OptionValue>(
pub fn option<OV: ConfigOptionType>(
&self,
config_option: &options::ConfigOption<OV>,
) -> Result<OV::OutputValue> {
Expand Down
24 changes: 12 additions & 12 deletions plugins/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub type DefaultBooleanConfigOption<'a> = ConfigOption<'a, config_type::DefaultB
pub type FlagConfigOption<'a> = ConfigOption<'a, config_type::Flag>;


pub trait OptionValue {
pub trait ConfigOptionType {
type OutputValue;
type DefaultValue;

Expand All @@ -172,7 +172,7 @@ pub trait OptionValue {
fn get_value_type() -> ValueType;
}

impl OptionValue for config_type::DefaultString {
impl ConfigOptionType for config_type::DefaultString {
type OutputValue = String;
type DefaultValue = &'static str;

Expand All @@ -192,7 +192,7 @@ impl OptionValue for config_type::DefaultString {
}
}

impl OptionValue for config_type::DefaultInteger {
impl ConfigOptionType for config_type::DefaultInteger {
type OutputValue = i64;
type DefaultValue = i64;

Expand All @@ -212,7 +212,7 @@ impl OptionValue for config_type::DefaultInteger {
}
}

impl OptionValue for config_type::DefaultBoolean {
impl ConfigOptionType for config_type::DefaultBoolean {
type OutputValue = bool;
type DefaultValue = bool;

Expand All @@ -231,7 +231,7 @@ impl OptionValue for config_type::DefaultBoolean {
}
}

impl OptionValue for config_type::Flag {
impl ConfigOptionType for config_type::Flag {
type OutputValue = bool;
type DefaultValue = ();

Expand All @@ -251,7 +251,7 @@ impl OptionValue for config_type::Flag {
}
}

impl OptionValue for config_type::String {
impl ConfigOptionType for config_type::String {
type OutputValue = Option<String>;
type DefaultValue = ();

Expand All @@ -275,7 +275,7 @@ impl OptionValue for config_type::String {
}
}

impl OptionValue for config_type::Integer {
impl ConfigOptionType for config_type::Integer {
type OutputValue = Option<i64>;
type DefaultValue = ();

Expand All @@ -298,7 +298,7 @@ impl OptionValue for config_type::Integer {
ValueType::Integer
}
}
impl OptionValue for config_type::Boolean {
impl ConfigOptionType for config_type::Boolean {
type OutputValue = Option<bool>;
type DefaultValue = ();

Expand Down Expand Up @@ -409,7 +409,7 @@ impl Value {
}

#[derive(Clone, Debug)]
pub struct ConfigOption<'a, V: OptionValue> {
pub struct ConfigOption<'a, V: ConfigOptionType> {
/// The name of the `ConfigOption`.
pub name: &'a str,
/// The default value of the `ConfigOption`
Expand All @@ -419,12 +419,12 @@ pub struct ConfigOption<'a, V: OptionValue> {
pub dynamic: bool,
}

impl<V: OptionValue> ConfigOption<'_, V> {
impl<V: ConfigOptionType> ConfigOption<'_, V> {
pub fn build(&self) -> UntypedConfigOption {
UntypedConfigOption {
name: self.name.to_string(),
value_type: V::get_value_type(),
default: <V as OptionValue>::convert_default(&self.default),
default: <V as ConfigOptionType>::convert_default(&self.default),
description: self.description.to_string(),
deprecated: self.deprecated,
dynamic: self.dynamic,
Expand Down Expand Up @@ -558,7 +558,7 @@ impl UntypedConfigOption {

impl<V> ConfigOption<'_, V>
where
V: OptionValue,
V: ConfigOptionType,
{
pub fn name(&self) -> &str {
&self.name
Expand Down

0 comments on commit 320dd93

Please sign in to comment.