pub struct ShellConfig {
pub suggest_timeout_ms: u64,
pub max_model_size: usize,
pub max_history_size: usize,
pub max_suggestions: usize,
pub max_prefix_length: usize,
pub min_prefix_length: usize,
pub min_quality_score: f32,
}Expand description
Configuration with safety limits.
These limits protect against resource exhaustion from malformed input or corrupted data.
§Example
use aprender_shell::config::ShellConfig;
let config = ShellConfig::default();
assert_eq!(config.suggest_timeout_ms, 100);
assert_eq!(config.max_suggestions, 10);
let custom = ShellConfig::default()
.with_suggest_timeout_ms(50)
.with_max_suggestions(5);
assert_eq!(custom.suggest_timeout_ms, 50);
assert_eq!(custom.max_suggestions, 5);Fields§
§suggest_timeout_ms: u64Maximum time for suggestion generation (ms)
max_model_size: usizeMaximum model file size (bytes)
max_history_size: usizeMaximum history file size (bytes)
max_suggestions: usizeMaximum number of suggestions to return
max_prefix_length: usizeMaximum prefix length to process
min_prefix_length: usizeMinimum prefix length to process
min_quality_score: f32Minimum quality score for suggestions (0.0 to 1.0)
Implementations§
Source§impl ShellConfig
impl ShellConfig
Sourcepub fn with_suggest_timeout_ms(self, timeout: u64) -> Self
pub fn with_suggest_timeout_ms(self, timeout: u64) -> Self
Set the suggestion timeout in milliseconds.
Sourcepub fn with_max_model_size(self, size: usize) -> Self
pub fn with_max_model_size(self, size: usize) -> Self
Set the maximum model size in bytes.
Sourcepub fn with_max_history_size(self, size: usize) -> Self
pub fn with_max_history_size(self, size: usize) -> Self
Set the maximum history file size in bytes.
Sourcepub fn with_max_suggestions(self, count: usize) -> Self
pub fn with_max_suggestions(self, count: usize) -> Self
Set the maximum number of suggestions.
Sourcepub fn with_max_prefix_length(self, length: usize) -> Self
pub fn with_max_prefix_length(self, length: usize) -> Self
Set the maximum prefix length.
Sourcepub fn with_min_prefix_length(self, length: usize) -> Self
pub fn with_min_prefix_length(self, length: usize) -> Self
Set the minimum prefix length.
Sourcepub fn with_min_quality_score(self, score: f32) -> Self
pub fn with_min_quality_score(self, score: f32) -> Self
Set the minimum quality score (0.0 to 1.0).
Sourcepub fn suggest_timeout(&self) -> Duration
pub fn suggest_timeout(&self) -> Duration
Get the suggestion timeout as a Duration.
Sourcepub fn is_model_size_valid(&self, size: usize) -> bool
pub fn is_model_size_valid(&self, size: usize) -> bool
Check if a model file size is within limits.
Sourcepub fn is_history_size_valid(&self, size: usize) -> bool
pub fn is_history_size_valid(&self, size: usize) -> bool
Check if a history file size is within limits.
Sourcepub fn is_prefix_valid(&self, prefix: &str) -> bool
pub fn is_prefix_valid(&self, prefix: &str) -> bool
Check if a prefix length is within limits.
Sourcepub fn truncate_prefix<'a>(&self, prefix: &'a str) -> &'a str
pub fn truncate_prefix<'a>(&self, prefix: &'a str) -> &'a str
Truncate prefix to max length if needed.
Source§impl ShellConfig
Preset configurations for different use cases.
impl ShellConfig
Preset configurations for different use cases.
Trait Implementations§
Source§impl Clone for ShellConfig
impl Clone for ShellConfig
Source§fn clone(&self) -> ShellConfig
fn clone(&self) -> ShellConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShellConfig
impl Debug for ShellConfig
Source§impl Default for ShellConfig
impl Default for ShellConfig
Source§impl PartialEq for ShellConfig
impl PartialEq for ShellConfig
impl StructuralPartialEq for ShellConfig
Auto Trait Implementations§
impl Freeze for ShellConfig
impl RefUnwindSafe for ShellConfig
impl Send for ShellConfig
impl Sync for ShellConfig
impl Unpin for ShellConfig
impl UnwindSafe for ShellConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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