pub struct ExternalDependency {
pub path: PathBuf,
pub fingerprint: Option<Fingerprint>,
}Expand description
One external file a lowering depended on: an #image / #figure raster or
a #bibliography source.
fingerprint is None when the path was not a readable regular file at
lowering time, so a file that later appears is as much a change as one
that is edited.
§Examples
use std::path::Path;
use mos_eval::ExternalDependency;
let dep = ExternalDependency::observe(Path::new("/nonexistent/x.png"));
assert_eq!(dep.fingerprint, None);
assert!(dep.is_current());Fields§
§path: PathBufThe resolved filesystem path that was read.
fingerprint: Option<Fingerprint>The file’s Fingerprint, or None when it could not be read.
Implementations§
Source§impl ExternalDependency
impl ExternalDependency
Sourcepub fn observe(path: impl Into<PathBuf>) -> Self
pub fn observe(path: impl Into<PathBuf>) -> Self
Record path with the fingerprint it has right now.
Sourcepub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
Whether the file on disk still matches the recorded fingerprint.
A stat settles the common cases: a file whose size, modification
time, and FileIdentity are unchanged is current, and a file that
appeared or vanished is not. The bytes are re-read and hashed only when
the stat differs or the fingerprint is racy,
so a touch that leaves the contents alone still counts as current,
while a same-size rewrite that restores the old mtime is caught by the
inode identity on Unix and by the racy window everywhere.
Trait Implementations§
Source§impl Clone for ExternalDependency
impl Clone for ExternalDependency
Source§fn clone(&self) -> ExternalDependency
fn clone(&self) -> ExternalDependency
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExternalDependency
impl Debug for ExternalDependency
impl Eq for ExternalDependency
Source§impl PartialEq for ExternalDependency
impl PartialEq for ExternalDependency
Source§fn eq(&self, other: &ExternalDependency) -> bool
fn eq(&self, other: &ExternalDependency) -> bool
self and other values to be equal, and is used by ==.