pub struct EnvSnapshot {
pub git: Option<GitSnapshot>,
}Expand description
Session-start environment snapshot.
Only git is captured today. Extend by adding fields (e.g. rust_toolchain,
node_version) and rendering them in [as_prompt_section].
Fields§
§git: Option<GitSnapshot>Implementations§
Source§impl EnvSnapshot
impl EnvSnapshot
Sourcepub fn capture(wd: &Path) -> Self
pub fn capture(wd: &Path) -> Self
Capture the current git state at wd. Blocking I/O — acceptable
at session start / ChangeDir, which run at most a few times per
process. Returns an empty snapshot (git: None) on any failure.
Sourcepub fn as_prompt_section(&self) -> String
pub fn as_prompt_section(&self) -> String
Render as a === GIT STATUS === block for splicing into the
system prompt. Returns String::new() when no git state exists
(so the caller can unconditionally push the result without
checking — empty string is a no-op).
Format (matches CC’s snapshot disclaimer pattern):
=== GIT STATUS (snapshot at session start, not live) ===
Branch: main
HEAD: 06f4537 feat(tuix): /context 命令
Status: 3 files modified
M src/foo.rs
M src/bar.rs
?? new.rs
This is a snapshot from session start. Use `bash` + `git status`
to check live state.Trait Implementations§
Source§impl Clone for EnvSnapshot
impl Clone for EnvSnapshot
Source§fn clone(&self) -> EnvSnapshot
fn clone(&self) -> EnvSnapshot
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 EnvSnapshot
impl Debug for EnvSnapshot
Source§impl Default for EnvSnapshot
impl Default for EnvSnapshot
Source§fn default() -> EnvSnapshot
fn default() -> EnvSnapshot
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EnvSnapshot
impl RefUnwindSafe for EnvSnapshot
impl Send for EnvSnapshot
impl Sync for EnvSnapshot
impl Unpin for EnvSnapshot
impl UnsafeUnpin for EnvSnapshot
impl UnwindSafe for EnvSnapshot
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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