Skip to main content

SessionDir

Struct SessionDir 

Source
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

Source

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.

Source

pub fn path(&self) -> &Path

The directory itself.

Source

pub fn id(&self) -> Option<SessionId>

The session’s id: the directory’s name, when it is one.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn started(&self) -> PathBuf

The plain, empty marker of a session an agent started in: its first app ran a whole frame.

Source

pub fn log(&self) -> PathBuf

The agent’s text log, unless a plugin keeps it elsewhere or not at all.

Source

pub fn launcher_lock(&self) -> PathBuf

Held by the launcher running the session while it lives.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn working_directory(&self) -> Option<PathBuf>

The session’s working directory, when Self::directory names one that still exists.

Trait Implementations§

Source§

impl Clone for SessionDir

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionDir

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.