use std::path::Path;
use serde_json::Value;
use crate::builder::builder_options::BuilderOptions;
use crate::{
provider::{CacheOptions, Features, GetOptionsPreferences},
schema::metadata::OptionsMetadata,
};
pub trait OptionsRegistry {
fn build(directory: impl AsRef<Path>) -> Result<Self, String>
where
Self: Sized;
fn build_from_directories(directories: &[impl AsRef<Path>]) -> Result<Self, String>
where
Self: Sized;
fn build_from_directories_with_options(
directories: &[impl AsRef<Path>],
options: BuilderOptions,
) -> Result<Self, String>
where
Self: Sized;
fn build_from_directories_with_schema(
directories: &[impl AsRef<Path>],
schema_path: impl AsRef<Path>,
) -> Result<Self, String>
where
Self: Sized,
{
let options = BuilderOptions {
schema_path: Some(schema_path.as_ref().to_path_buf()),
..BuilderOptions::default()
};
Self::build_from_directories_with_options(directories, options)
}
fn build_with_options(
directory: impl AsRef<Path>,
options: BuilderOptions,
) -> Result<Self, String>
where
Self: Sized;
fn build_with_schema(
directory: impl AsRef<Path>,
schema_path: impl AsRef<Path>,
) -> Result<Self, String>
where
Self: Sized,
{
let options = BuilderOptions {
schema_path: Some(schema_path.as_ref().to_path_buf()),
..BuilderOptions::default()
};
Self::build_with_options(directory, options)
}
fn get_aliases(&self) -> Vec<String>;
fn get_features_and_aliases(&self) -> Vec<String>;
fn get_all_options(
&self,
feature_names: &[impl AsRef<str>],
cache_options: Option<&CacheOptions>,
preferences: Option<&GetOptionsPreferences>,
) -> Result<Value, String>;
fn get_canonical_feature_name(&self, feature_name: &str) -> Result<String, String>;
fn get_canonical_feature_names(
&self,
feature_names: &[impl AsRef<str>],
) -> Result<Vec<String>, String>;
fn get_feature_metadata(&self, canonical_feature_name: &str) -> Option<OptionsMetadata>;
fn get_features(&self) -> Vec<String>;
fn get_features_referencing_file(&self, relative_path: &str) -> Option<Vec<String>>;
fn get_features_with_metadata(&self) -> Features;
fn get_filtered_feature_names(
&self,
feature_names: &[impl AsRef<str>],
preferences: Option<&GetOptionsPreferences>,
) -> Result<Vec<String>, String>;
fn get_options(&self, key: &str, feature_names: &[impl AsRef<str>]) -> Result<Value, String>;
fn get_options_with_preferences(
&self,
key: &str,
feature_names: &[impl AsRef<str>],
cache_options: Option<&CacheOptions>,
preferences: Option<&GetOptionsPreferences>,
) -> Result<Value, String>;
fn has_conditions(&self, canonical_feature_name: &str) -> bool;
fn map_feature_names(
&self,
feature_names: &[impl AsRef<str>],
preferences: Option<&GetOptionsPreferences>,
) -> Result<Vec<Option<String>>, String>;
}