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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.