pub struct SessionDir(/* private fields */);Expand description
A session’s directory. The agent keeps the session there through its
store, which a plugin may replace (by default in the folders logs,
blobs and files), so only the plain files beside the store are
named here: the markers of a session an agent started in
(Self::started), logged to (Self::is_saved) and being deleted
(Self::is_deleting), the text log, the lock of the launcher running
it, its working directory, its name and the session to switch to.
Implementations§
Source§impl SessionDir
impl SessionDir
Sourcepub fn at(path: impl Into<PathBuf>) -> Self
pub fn at(path: impl Into<PathBuf>) -> Self
The session kept in the directory path, such as one a command
names, rather than one of a Home’s.
Sourcepub fn is_saved(&self) -> bool
pub fn is_saved(&self) -> bool
Whether an agent of the session wrote its log, so it can be
resumed: the session has the marker Self::mark_saved writes and
is not being deleted.
Sourcepub fn is_deleting(&self) -> bool
pub fn is_deleting(&self) -> bool
Whether the session is being deleted: it has the marker
Self::mark_deleting writes. Listings leave it out, and the
agent’s next start finishes deleting it.
Sourcepub fn mark_deleting(&self) -> Result<()>
pub fn mark_deleting(&self) -> Result<()>
Marks the session as being deleted, before anything of it is removed, so a delete a crash cuts short is finished later and never leaves a half-removed session to resume.
§Errors
When the marker cannot be written.
Sourcepub fn mark_saved(&self) -> Result<()>
pub fn mark_saved(&self) -> Result<()>
Marks the session saved, as the agent’s store does when it first writes an agent’s log there.
§Errors
When the marker cannot be written.
Sourcepub fn started(&self) -> PathBuf
pub fn started(&self) -> PathBuf
The plain, empty marker of a session an agent started in: its first app ran a whole frame.
Sourcepub fn log(&self) -> PathBuf
pub fn log(&self) -> PathBuf
The agent’s text log, unless a plugin keeps it elsewhere or not at all.
Sourcepub fn launcher_lock(&self) -> PathBuf
pub fn launcher_lock(&self) -> PathBuf
Held by the launcher running the session while it lives.
Sourcepub fn hold(&self) -> Result<Option<File>>
pub fn hold(&self) -> Result<Option<File>>
Takes Self::launcher_lock, creating the directory, unless
another launcher holds it: the lock that marks the session as run,
held until the returned file is dropped or the process dies. A
launcher holds it while it runs the session, and a program that
changes a saved session holds it while it does, so no launcher
starts the session meanwhile. None when another holds it.
§Errors
When the directory or the lock file cannot be made, or locking fails otherwise.
Sourcepub fn runs_elsewhere(&self) -> bool
pub fn runs_elsewhere(&self) -> bool
Whether a launcher runs the session: one holds
Self::launcher_lock. A command that rewrites or removes a saved
session leaves such a one alone.
Sourcepub fn directory(&self) -> PathBuf
pub fn directory(&self) -> PathBuf
The working directory the session runs in, as plain text: written when the session starts, and where the launcher starts the agent when it resumes the session from elsewhere.
Sourcepub fn name(&self) -> Option<String>
pub fn name(&self) -> Option<String>
The name the user gave the session, kept as plain text in the
file name beside Self::directory, so the launcher finds the
session by it (Home::find) without opening its store. Like the
directory, it is readable on disk when the store seals what it
keeps.
Sourcepub fn set_name(&self, name: Option<&str>) -> Result<()>
pub fn set_name(&self, name: Option<&str>) -> Result<()>
Names the session, or removes its name with None or a blank name.
The name is written beside the file and renamed over it, so a
reader sees the old name or the new one, never a part.
§Errors
When the file cannot be written or removed.
Sourcepub fn switch(&self) -> PathBuf
pub fn switch(&self) -> PathBuf
Written by the agent before it exits with RELOAD_EXIT_CODE to
run another session: the SessionId to resume, or nothing for a
new session. The launcher reads and removes it.
Sourcepub fn working_directory(&self) -> Option<PathBuf>
pub fn working_directory(&self) -> Option<PathBuf>
The session’s working directory, when Self::directory names one
that still exists.