pub struct SessionManager { /* private fields */ }Expand description
Manages multiple REPL sessions
Thread-safe session storage using Arc<RwLock
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn create(
&self,
session_id: SessionId,
mode: ReplMode,
) -> Result<SessionId, SessionError>
pub fn create( &self, session_id: SessionId, mode: ReplMode, ) -> Result<SessionId, SessionError>
Create a new session
§Errors
Returns SessionError::AlreadyExists if a session with the same ID already exists.
§Example
use oxur_repl::server::SessionManager;
use oxur_repl::protocol::{ReplMode, SessionId};
let manager = SessionManager::new();
let session_id = manager.create(SessionId::new("session-1"), ReplMode::Lisp).unwrap();
assert_eq!(session_id, SessionId::new("session-1"));Sourcepub fn create_with_compilation(
&self,
session_id: SessionId,
mode: ReplMode,
) -> Result<SessionId, SessionError>
pub fn create_with_compilation( &self, session_id: SessionId, mode: ReplMode, ) -> Result<SessionId, SessionError>
Create a new session with full compilation support
This creates a session with the full compilation pipeline including session directory, artifact cache, and subprocess executor.
§Errors
Returns SessionError::AlreadyExists if a session with the same ID already exists.
Returns SessionError::EvalFailed if the compilation pipeline cannot be initialized.
Sourcepub async fn eval(
&self,
session_id: &SessionId,
code: impl AsRef<str>,
) -> Result<EvalResult, SessionError>
pub async fn eval( &self, session_id: &SessionId, code: impl AsRef<str>, ) -> Result<EvalResult, SessionError>
Execute an async operation with a session
Takes ownership of the evaluation, executes it, and updates the session. This avoids lifetime issues with async closures.
§Errors
Returns SessionError::NotFound if the session doesn’t exist.
Returns SessionError::EvalFailed if evaluation fails due to:
- Syntax errors in the code
- Type errors during compilation
- Runtime errors during execution
- Compilation errors
- Unsupported operations for the current tier
Returns SessionError::LockPoisoned if the internal lock is poisoned.
Sourcepub fn clone_session(
&self,
source_id: &SessionId,
target_id: SessionId,
) -> Result<SessionId, SessionError>
pub fn clone_session( &self, source_id: &SessionId, target_id: SessionId, ) -> Result<SessionId, SessionError>
Clone an existing session
Creates a new session with the same cache and state as the source session, but with a different session ID and reset statistics.
§Errors
Returns SessionError::NotFound if the source session doesn’t exist.
Returns SessionError::AlreadyExists if the target session ID is already in use.
Sourcepub fn close(&self, session_id: &SessionId) -> Result<(), SessionError>
pub fn close(&self, session_id: &SessionId) -> Result<(), SessionError>
Close a session
Removes the session and frees its resources.
§Errors
Returns SessionError::NotFound if the session doesn’t exist.
Sourcepub fn list(&self) -> Result<Vec<SessionInfo>, SessionError>
pub fn list(&self) -> Result<Vec<SessionInfo>, SessionError>
List all active sessions
Returns information about all currently active sessions.
§Errors
Returns SessionError::LockPoisoned if the internal lock is poisoned.
Sourcepub fn get_info(
&self,
session_id: &SessionId,
) -> Result<SessionInfo, SessionError>
pub fn get_info( &self, session_id: &SessionId, ) -> Result<SessionInfo, SessionError>
Get information about a specific session
§Errors
Returns SessionError::NotFound if the session doesn’t exist.
Sourcepub fn get_stats_collector(
&self,
session_id: &SessionId,
) -> Result<Arc<Mutex<EvalMetrics>>, SessionError>
pub fn get_stats_collector( &self, session_id: &SessionId, ) -> Result<Arc<Mutex<EvalMetrics>>, SessionError>
Get the statistics collector for a session
Returns a shared reference to the session’s StatsCollector for detailed metrics access.
§Errors
Returns SessionError::NotFound if the session doesn’t exist.
Returns SessionError::LockPoisoned if the internal lock is poisoned.
Sourcepub fn get_usage_metrics(
&self,
session_id: &SessionId,
) -> Result<Arc<Mutex<UsageMetrics>>, SessionError>
pub fn get_usage_metrics( &self, session_id: &SessionId, ) -> Result<Arc<Mutex<UsageMetrics>>, SessionError>
Get the usage metrics collector for a session
Returns a shared reference to the session’s UsageMetrics for command frequency tracking.
§Errors
Returns SessionError::NotFound if the session doesn’t exist.
Returns SessionError::LockPoisoned if the internal lock is poisoned.
Sourcepub fn get_resource_stats(
&self,
session_id: &SessionId,
) -> Result<(Option<DirStats>, Option<CacheStats>), SessionError>
pub fn get_resource_stats( &self, session_id: &SessionId, ) -> Result<(Option<DirStats>, Option<CacheStats>), SessionError>
Get resource statistics for a session
Returns (session_dir_stats, artifact_cache_stats) for the given session.
§Errors
Returns SessionError::NotFound if the session doesn’t exist.
Returns SessionError::LockPoisoned if the internal lock is poisoned.
Sourcepub fn get_subprocess_stats(
&self,
session_id: &SessionId,
) -> Result<Option<SubprocessMetricsSnapshot>, SessionError>
pub fn get_subprocess_stats( &self, session_id: &SessionId, ) -> Result<Option<SubprocessMetricsSnapshot>, SessionError>
Get subprocess statistics for a session
Returns subprocess metrics snapshot for the given session.
§Errors
Returns SessionError::NotFound if the session doesn’t exist.
Returns SessionError::LockPoisoned if the internal lock is poisoned.
Sourcepub fn count(&self) -> Result<usize, SessionError>
pub fn count(&self) -> Result<usize, SessionError>
Get the number of active sessions
§Errors
Returns SessionError::LockPoisoned if the internal lock is poisoned.
Trait Implementations§
Source§impl Clone for SessionManager
impl Clone for SessionManager
Source§fn clone(&self) -> SessionManager
fn clone(&self) -> SessionManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionManager
impl Debug for SessionManager
Auto Trait Implementations§
impl Freeze for SessionManager
impl RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnwindSafe for SessionManager
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);