BaseConfig

Struct BaseConfig 

Source
pub struct BaseConfig {
    pub config_path: PathBuf,
    pub database_path: PathBuf,
    pub analysis_options: AnalysisOptions,
    pub m: Array2<f32>,
}
Expand description

The minimum configuration an application needs to work with a Library.

Fields§

§config_path: PathBuf

The path to where the configuration file should be stored, e.g. /home/foo/.local/share/bliss-rs/config.json

§database_path: PathBuf

The path to where the database file should be stored, e.g. /home/foo/.local/share/bliss-rs/bliss.db

§analysis_options: AnalysisOptions

The analysis options set in the database (number of CPU cores for the analysis, desired feature version…)

§m: Array2<f32>

The mahalanobis matrix used for mahalanobis distance. Used to customize the distance metric beyond simple euclidean distance. Uses ndarray’s serde feature for serialization / deserialization. Field would look like this: “m”: {“v”: 1, “dim”: [20, 20], “data”: [1.0, 0.0, …, 1.0]}

Implementations§

Source§

impl BaseConfig

Source

pub fn new( config_path: Option<PathBuf>, database_path: Option<PathBuf>, analysis_options: Option<AnalysisOptions>, ) -> Result<Self>

Create a new, basic config. Upon calls of Config.write(), it will be written to config_path. Any path omitted will instead default to a “clever” path using data directory inference. The “clever” thinking is as follows:

  • If the user specified only one of the paths, it will put the other file in the same folder as the given path.
  • If the user specified both paths, it will go with what the user chose.
  • If the user didn’t select any path, it will try to put everything in the user’s configuration directory, i.e. XDG_CONFIG_HOME.

The number of cores is the number of cores that should be used for any analysis. If not provided, it will default to the computer’s number of cores.

Trait Implementations§

Source§

impl AppConfigTrait for BaseConfig

Source§

fn base_config(&self) -> &BaseConfig

This trait should return the BaseConfig from the parent, user-created Config.
Source§

fn base_config_mut(&mut self) -> &mut BaseConfig

This trait should return the BaseConfig from the parent, user-created Config.
Source§

fn serialize_config(&self) -> Result<String>

Convert the current config to a String, to be written to a file. Read more
Source§

fn set_number_cores(&mut self, number_cores: NonZeroUsize) -> Result<()>

Set the number of desired cores for analysis, and write it to the configuration file.
Source§

fn set_features_version( &mut self, features_version: FeaturesVersion, ) -> Result<()>

Set the desired version for analysis, and write it to the configuration file.
Source§

fn get_features_version(&self) -> FeaturesVersion

Get the number of desired cores for analysis, and write it to the configuration file.
Source§

fn get_number_cores(&self) -> NonZeroUsize

Get the number of desired cores for analysis, and write it to the configuration file.
Source§

fn deserialize_config(data: &str) -> Result<Self>

Default implementation to load a config from a JSON file. Reads from a string. Read more
Source§

fn from_path(path: &str) -> Result<Self>

Load a config from the specified path, using deserialize_config. Read more
Source§

fn write(&self) -> Result<()>

Write the configuration to a file using AppConfigTrait::serialize_config. Read more
Source§

impl Clone for BaseConfig

Source§

fn clone(&self) -> BaseConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BaseConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BaseConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for BaseConfig

Source§

fn eq(&self, other: &BaseConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BaseConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BaseConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,