pub struct IgnoreFile {
pub ignore: Vec<IgnoreEntry>,
}Expand description
The suppressions a project has decided to keep.
Every operation that changes the file takes it by value and hands back the changed one, so a caller cannot half-apply a change and cannot be handed a file that something else is still writing to.
Fields§
§ignore: Vec<IgnoreEntry>Implementations§
Source§impl IgnoreFile
impl IgnoreFile
Sourcepub fn load(root: &Path) -> Self
pub fn load(root: &Path) -> Self
Read it, or an empty one if there is nothing readable there.
Unlike a baseline, an absent ignore file is the ordinary case: most projects suppress nothing, and that is indistinguishable from a project that has not started yet.
Sourcepub fn save(&self, root: &Path) -> Result<()>
pub fn save(&self, root: &Path) -> Result<()>
Write it to the project root, or take the file away when there is nothing left to record.
An empty suppression list makes exactly the claim that no suppression
list makes, and load cannot tell them apart. cleanup pruning the
last entry is the one path that produces one, and a file reading
ignore = [] is residue rather than a record.
§Errors
Returns the I/O error if the file cannot be serialized, written or removed.
Sourcepub fn remove_from(root: &Path) -> Result<()>
pub fn remove_from(root: &Path) -> Result<()>
Take the ignore file away, and say nothing if it was not there.
§Errors
Returns the I/O error if the file exists and cannot be removed.
Sourcepub fn with_ignored(
self,
fingerprint: &Fingerprint,
reason: Option<String>,
members: Vec<String>,
) -> Self
pub fn with_ignored( self, fingerprint: &Fingerprint, reason: Option<String>, members: Vec<String>, ) -> Self
The same file with fingerprint suppressed, or unchanged if it already
was.
Sourcepub fn without(self, fingerprint: &str) -> (Self, bool)
pub fn without(self, fingerprint: &str) -> (Self, bool)
The same file without fingerprint, and whether it was there to remove.
Sourcepub fn contains(&self, fingerprint: &Fingerprint) -> bool
pub fn contains(&self, fingerprint: &Fingerprint) -> bool
Whether this fingerprint is suppressed.
Sourcepub fn retain_unsuppressed(
&self,
groups: Vec<DuplicateGroup>,
) -> Vec<DuplicateGroup>
pub fn retain_unsuppressed( &self, groups: Vec<DuplicateGroup>, ) -> Vec<DuplicateGroup>
The groups this file does not suppress.
Sourcepub fn stale(&self, live: &HashSet<Fingerprint>) -> Vec<&IgnoreEntry>
pub fn stale(&self, live: &HashSet<Fingerprint>) -> Vec<&IgnoreEntry>
The entries whose fingerprint no longer matches anything live.
An entry whose fingerprint is not valid hex is always stale: nothing this tool produces could match it.
Sourcepub fn without_stale(
self,
live: &HashSet<Fingerprint>,
) -> (Self, Vec<IgnoreEntry>)
pub fn without_stale( self, live: &HashSet<Fingerprint>, ) -> (Self, Vec<IgnoreEntry>)
The same file with the stale entries taken out, and those entries.