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:
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
Dropin
The scope for drop-in replacements, it has the highest priority.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for DTScope
impl<'de> Deserialize<'de> for DTScope
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for DTScope
impl Ord for DTScope
sourceimpl PartialOrd<DTScope> for DTScope
impl PartialOrd<DTScope> for DTScope
sourcefn partial_cmp(&self, other: &DTScope) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Eq for DTScope
impl StructuralEq for DTScope
impl StructuralPartialEq for DTScope
Auto Trait Implementations
impl RefUnwindSafe for DTScope
impl Send for DTScope
impl Sync for DTScope
impl Unpin for DTScope
impl UnwindSafe for DTScope
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more