pub struct ShellSample { /* private fields */ }Expand description
A shell command sample with execution context.
Represents a single training example for shell autocomplete, including command history, current input prefix, and working directory context.
§Example
use aprender::synthetic::shell::ShellSample;
let sample = ShellSample::new("git st", "git status")
.with_history(vec!["cd project".to_string()])
.with_cwd("/home/user/project");
assert_eq!(sample.prefix(), "git st");
assert_eq!(sample.completion(), "git status");Implementations§
Source§impl ShellSample
impl ShellSample
Sourcepub fn new(prefix: impl Into<String>, completion: impl Into<String>) -> Self
pub fn new(prefix: impl Into<String>, completion: impl Into<String>) -> Self
Create a new shell sample.
§Arguments
prefix- Current partial inputcompletion- Full completed command
Sourcepub fn with_history(self, history: Vec<String>) -> Self
pub fn with_history(self, history: Vec<String>) -> Self
Add command history context.
Sourcepub fn completion(&self) -> &str
pub fn completion(&self) -> &str
Get the completion.
Sourcepub fn command_name(&self) -> Option<&str>
pub fn command_name(&self) -> Option<&str>
Extract the command name (first token).
Sourcepub fn is_valid_completion(&self) -> bool
pub fn is_valid_completion(&self) -> bool
Check if the completion starts with the prefix.
Trait Implementations§
Source§impl Clone for ShellSample
impl Clone for ShellSample
Source§fn clone(&self) -> ShellSample
fn clone(&self) -> ShellSample
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShellSample
impl Debug for ShellSample
Source§impl PartialEq for ShellSample
impl PartialEq for ShellSample
impl StructuralPartialEq for ShellSample
Auto Trait Implementations§
impl Freeze for ShellSample
impl RefUnwindSafe for ShellSample
impl Send for ShellSample
impl Sync for ShellSample
impl Unpin for ShellSample
impl UnsafeUnpin for ShellSample
impl UnwindSafe for ShellSample
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
Mutably borrows from an owned value. Read more
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>
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 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>
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