Skip to main content

Registry

Struct Registry 

Source
pub struct Registry {
    pub containers: Vec<Registered>,
}
Expand description

The containers QCode started, in the order it first started them.

Fields§

§containers: Vec<Registered>

Every container, each name once.

Implementations§

Source§

impl Registry

Source

pub fn file() -> Option<PathBuf>

Where the list of this user is kept: containers.toml in QCode’s data folder, or None on a machine that names no home, where nothing is recorded and so nothing is stopped.

Source

pub fn is_empty(&self) -> bool

Whether the list holds nothing.

Source

pub fn add(&mut self, name: &str, engine: EngineKind) -> bool

Adds name in engine, unless it is there already or is not one of QCode’s names. Answers whether the list changed.

Source

pub fn load(path: &Path) -> Loaded<Self>

Reads the list at path.

A file that is not there is an empty list: nothing was started yet, or everything was stopped. A file that cannot be read is an empty list with a diagnostic that says why.

Source

pub fn parse(file: &str, text: &str) -> Loaded<Self>

Reads a list from text, reporting problems against file.

An entry that is not one of QCode’s containers, or names no engine QCode drives, is left out with a diagnostic; a name listed twice is kept once.

Source

pub fn to_toml(&self) -> String

The file as it is written to disk.

Source

pub fn save(&self, path: &Path) -> Result<()>

Writes the list to path atomically, making its folder first when it is not there.

§Errors

Returns the I/O error when the folder or the file cannot be written.

Source

pub fn record( path: &Path, name: &str, engine: EngineKind, ) -> Result<Vec<Diagnostic>>

Notes in the list at path that QCode started the container name in engine, and answers what was wrong with the file it found there.

The file is only written when the name is new, so the tab opened for the hundredth time costs a read and nothing more, and a watcher of the file is not woken for nothing. A file that was damaged is written again with what could be read of it and the new name: the container that just started would otherwise never be stopped, and the problems are answered so the person hears of them. A name that is not QCode’s is not written at all.

This reads and writes the disk, so it belongs on a background thread.

§Errors

Returns the I/O error when the file cannot be written.

Source

pub fn replace(path: &Path, remaining: &Self) -> Result<()>

Writes remaining to the list at path in place of what it held, which is what stopping the containers does once it is through: only what could not be stopped stays listed.

§Errors

Returns the I/O error when the file cannot be written.

Trait Implementations§

Source§

impl Clone for Registry

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 Registry

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Registry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Registry

Source§

impl PartialEq for Registry

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Registry

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
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.