PluginConfigBuilder

Struct PluginConfigBuilder 

Source
pub struct PluginConfigBuilder { /* private fields */ }
Expand description

Builder for creating plugin configurations

The PluginConfigBuilder provides a fluent interface for constructing plugin configurations with various parameters and runtime settings. It ensures type safety and provides convenient methods for common configuration patterns.

§Examples

use sklears_core::plugin::{PluginConfigBuilder, PluginParameter, LogLevel};

let config = PluginConfigBuilder::new()
    .with_parameter("learning_rate", PluginParameter::Float(0.01))
    .with_parameter("max_iterations", PluginParameter::Int(1000))
    .with_parameter("use_bias", PluginParameter::Bool(true))
    .with_threads(4)
    .with_memory_limit(1024 * 1024 * 1024) // 1GB
    .with_timeout(30000) // 30 seconds
    .with_gpu(true)
    .with_log_level(LogLevel::Info)
    .with_setting("backend", "cuda")
    .build();

Implementations§

Source§

impl PluginConfigBuilder

Source

pub fn new() -> Self

Create a new config builder

Initializes a new builder with default configuration values.

§Examples
use sklears_core::plugin::PluginConfigBuilder;

let builder = PluginConfigBuilder::new();
let config = builder.build();
Source

pub fn with_parameter(self, key: &str, value: PluginParameter) -> Self

Add a parameter to the configuration

Adds a named parameter with the specified value to the configuration. This method can be chained to add multiple parameters.

§Arguments
  • key - The parameter name
  • value - The parameter value
§Examples
use sklears_core::plugin::{PluginConfigBuilder, PluginParameter};

let config = PluginConfigBuilder::new()
    .with_parameter("learning_rate", PluginParameter::Float(0.01))
    .with_parameter("regularization", PluginParameter::Float(0.001))
    .build();
Source

pub fn with_parameters(self, params: HashMap<String, PluginParameter>) -> Self

Add multiple parameters at once

Convenience method for adding multiple parameters from a map.

§Arguments
  • params - Map of parameter names to values
Source

pub fn with_threads(self, threads: usize) -> Self

Set the number of threads to use

Configures the number of threads that the plugin should use for parallel processing. If not set, the plugin will use its default threading behavior.

§Arguments
  • threads - Number of threads to use
§Examples
use sklears_core::plugin::PluginConfigBuilder;

let config = PluginConfigBuilder::new()
    .with_threads(8)
    .build();
Source

pub fn with_memory_limit(self, limit: usize) -> Self

Set memory limit in bytes

Configures the maximum amount of memory that the plugin should use. This can help prevent out-of-memory errors in resource-constrained environments.

§Arguments
  • limit - Memory limit in bytes
§Examples
use sklears_core::plugin::PluginConfigBuilder;

let config = PluginConfigBuilder::new()
    .with_memory_limit(2 * 1024 * 1024 * 1024) // 2GB
    .build();
Source

pub fn with_timeout(self, timeout_ms: u64) -> Self

Set timeout in milliseconds

Configures the maximum time that plugin operations should take before timing out. This can help prevent hanging operations.

§Arguments
  • timeout_ms - Timeout in milliseconds
§Examples
use sklears_core::plugin::PluginConfigBuilder;

let config = PluginConfigBuilder::new()
    .with_timeout(60000) // 1 minute
    .build();
Source

pub fn with_gpu(self, use_gpu: bool) -> Self

Enable or disable GPU acceleration

Configures whether the plugin should use GPU acceleration if available.

§Arguments
  • use_gpu - Whether to use GPU acceleration
§Examples
use sklears_core::plugin::PluginConfigBuilder;

let config = PluginConfigBuilder::new()
    .with_gpu(true)
    .build();
Source

pub fn with_log_level(self, level: LogLevel) -> Self

Set logging level

Configures the verbosity of logging output from the plugin.

§Arguments
  • level - The logging level to use
§Examples
use sklears_core::plugin::{PluginConfigBuilder, LogLevel};

let config = PluginConfigBuilder::new()
    .with_log_level(LogLevel::Debug)
    .build();
Source

pub fn with_setting(self, key: &str, value: &str) -> Self

Add a plugin-specific setting

Adds a custom setting that is specific to the plugin being configured. These settings are typically used for plugin-specific configuration that doesn’t fit into the standard parameter system.

§Arguments
  • key - The setting name
  • value - The setting value
§Examples
use sklears_core::plugin::PluginConfigBuilder;

let config = PluginConfigBuilder::new()
    .with_setting("backend", "tensorflow")
    .with_setting("device", "/gpu:0")
    .build();
Source

pub fn with_settings(self, settings: HashMap<String, String>) -> Self

Add multiple settings at once

Convenience method for adding multiple plugin-specific settings.

§Arguments
  • settings - Map of setting names to values
Source

pub fn build(self) -> PluginConfig

Build the final configuration

Consumes the builder and returns the constructed configuration.

§Returns

The configured PluginConfig instance.

§Examples
use sklears_core::plugin::{PluginConfigBuilder, PluginParameter};

let config = PluginConfigBuilder::new()
    .with_parameter("learning_rate", PluginParameter::Float(0.01))
    .with_threads(4)
    .build();
Source

pub fn config(&self) -> &PluginConfig

Get a reference to the current configuration

Returns a reference to the configuration being built without consuming the builder. This can be useful for inspecting the current state during construction.

§Returns

A reference to the current configuration.

Source

pub fn validate(&self) -> Result<()>

Validate the current configuration

Validates the current configuration state without building it. This can be useful for checking configuration validity during the building process.

§Returns

Ok(()) if the configuration is valid, or an error describing what is invalid.

Source

pub fn clone_builder(&self) -> Self

Clone the builder

Creates a copy of the current builder state, allowing for branching configuration construction.

§Returns

A cloned builder with the same configuration state.

Source§

impl PluginConfigBuilder

Convenience functions for common plugin configurations

Source

pub fn cpu_optimized() -> Self

Create a configuration optimized for CPU-intensive tasks

Sets up a configuration with appropriate threading and resource settings for CPU-bound algorithms.

Source

pub fn gpu_optimized() -> Self

Create a configuration optimized for GPU acceleration

Sets up a configuration with GPU acceleration enabled and appropriate resource settings.

Source

pub fn development() -> Self

Create a configuration for development/debugging

Sets up a configuration with verbose logging and longer timeouts suitable for development environments.

Source

pub fn production() -> Self

Create a configuration for production environments

Sets up a configuration with optimized settings for production use, including appropriate resource limits and logging levels.

Trait Implementations§

Source§

impl Clone for PluginConfigBuilder

Source§

fn clone(&self) -> PluginConfigBuilder

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 PluginConfigBuilder

Source§

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

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

impl Default for PluginConfigBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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