pub struct Source { /* private fields */ }Expand description
The last published vocabulary of one file plus one staged candidate. It reads only the path it is given and knows no default or home path.
Two equal observations are a settling heuristic: a writer paused across both can still expose an incomplete but valid file. This does not prove that an editor save completed.
Implementations§
Source§impl Source
impl Source
Sourcepub fn current(&self) -> Option<Arc<Vocabulary>>
pub fn current(&self) -> Option<Arc<Vocabulary>>
Share the last published vocabulary; None until the first publication.
Sourcepub fn observe(&mut self, path: &Path) -> Result<Observation, SourceError>
pub fn observe(&mut self, path: &Path) -> Result<Observation, SourceError>
Read a bounded candidate without writing the source. Call on a serialized reload path,
outside input callbacks. The first valid read stages a candidate and returns
Observation::Pending; a second read with equal metadata and bytes publishes it. An
initial valid empty file also requires two equal observations.
§Errors
A SourceError if the file can’t be read, isn’t a regular file, exceeds the bound,
changes during the read or doesn’t parse. Staging is discarded; the published snapshot
stays.