pub struct Session {
pub id: String,
pub state: SessionState,
pub history: Vec<HistoryEntry>,
pub env_vars: HashMap<String, String>,
pub aliases: HashMap<String, String>,
pub statistics: SessionStatistics,
pub stats: UserStats,
pub challenge_manager: ChallengeManager,
}Expand description
Represents a user session
Fields§
§id: String§state: SessionState§history: Vec<HistoryEntry>§env_vars: HashMap<String, String>§aliases: HashMap<String, String>§statistics: SessionStatistics§stats: UserStats§challenge_manager: ChallengeManagerImplementations§
Source§impl Session
impl Session
Sourcepub fn record_command(
&mut self,
command: String,
exit_code: Option<i32>,
duration_ms: Option<u64>,
)
pub fn record_command( &mut self, command: String, exit_code: Option<i32>, duration_ms: Option<u64>, )
Record a command in history
Sourcepub fn set_env_var(&mut self, key: String, value: String)
pub fn set_env_var(&mut self, key: String, value: String)
Set an environment variable
Sourcepub fn get_env_var(&self, key: &str) -> Option<&String>
pub fn get_env_var(&self, key: &str) -> Option<&String>
Get an environment variable
Sourcepub fn expand_aliases(&self, input: &str) -> String
pub fn expand_aliases(&self, input: &str) -> String
Expand aliases in a command
Sourcepub fn change_directory(&mut self, path: PathBuf) -> Result<()>
pub fn change_directory(&mut self, path: PathBuf) -> Result<()>
Change directory and update state
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
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