DTScope

Enum DTScope 

Source
pub enum DTScope {
    General,
    App,
    Dropin,
}
Expand description

Scope of a group, used to resolve priority of possibly duplicated items, to ensure every target path is pointed from only one source item.

The order of priority is:

Dropin > App > General

Within the same scope, the first defined group in the config file for DT has the highest priority, later defined groups have lower priorities.

Groups without a given scope are treated as of General scope.

§Example

When you want to populate all your config files for apps that follows the XDG standard, you might write a config file for DT that looks like this:

[[local]]
name = "xdg_config_home"
base = "/path/to/your/xdg/config/directory"
sources = ["*"]
target = "~/.config"

Let’s say after some weeks or months, you have decided to also include /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf to your fontconfig directory, which is ~/.config/fontconfig/conf.d, you do so by adding another [[local]] group into your config file for DT:

[[local]]
name = "fontconfig-system"
base = "/usr/share/fontconfig/conf.avail"
sources = ["11-lcdfilter-default.conf"]
target = "~/.config/fontconfig/conf.d"

A problem arises when you also maintain a version of 11-lcdfilter-default.conf of your own: If DT syncs the fontconfig-system group last, the resulting config file in your $XDG_CONFIG_HOME is the system version; While if DT syncs the xdg_config_home group last, that file ended up being your previously maintained version.

Actually, DT is quite predictable: it only performs operations in the order defined in the config file for your groups. By defining the fontconfig-system group last, you can completely avoid the ambiguity above.

However, since the config file was written by you, a human, and humans are notorious for making mistakes, it would be great if DT could always know what to do when duplicated items are discovered in the config file. Instead of putting the groups with higher priority at the end of your config file, you could simply define scopes in their definitions:

[[local]]
name = "fontconfig-system"
scope = "Dropin"
...
[[local]]
name = "xdg_config_home"
scope = "General"
...

Now, with the scope being set, DT will first remove the source item 11-lcdfilter-default.conf (if it exists) from group xdg_config_home, then perform its syncing process.

This is also useful with dt-cli’s -l|--local-name option, which gives you more granular control over how items are synced.

Variants§

§

General

The scope with lowest priority, this is the default scope, recommended for directories that contains config files for many un-categorized applications.

§

App

The scope for a specific app, it’s priority is higher than General while lower than Dropin.

§

Dropin

The scope for drop-in replacements, it has the highest priority.

Trait Implementations§

Source§

impl Clone for DTScope

Source§

fn clone(&self) -> DTScope

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DTScope

Source§

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

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

impl Default for DTScope

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for DTScope

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Ord for DTScope

Source§

fn cmp(&self, other: &DTScope) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for DTScope

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for DTScope

Source§

fn partial_cmp(&self, other: &DTScope) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for DTScope

Source§

impl StructuralPartialEq for DTScope

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,