pub struct Opened {
pub mark: Mark,
/* private fields */
}Expand description
A session that is open, with its content file launched and its directory watched.
Fields§
§mark: MarkWhat the platform recorded about where the container came from, carried onto the content file.
Implementations§
Source§impl Opened
impl Opened
Sourcepub fn content_path(&self) -> PathBuf
pub fn content_path(&self) -> PathBuf
Where the content file was put.
Sourcepub fn saw_a_change(&self) -> bool
pub fn saw_a_change(&self) -> bool
Whether the content file has been seen to change since the session opened.
Sourcepub fn application_is_working(&self) -> Result<bool>
pub fn application_is_working(&self) -> Result<bool>
Whether the target application has anything of its own in the content directory (concept 6.1).
§Errors
Where the content directory cannot be read.
Sourcepub fn pump(&mut self) -> Result<bool, Error>
pub fn pump(&mut self) -> Result<bool, Error>
Take whatever the watch has to say, and write back once if the content file was among it.
Once, rather than once per event. A single save arrives as several events — a temporary sibling, a rename, a metadata touch — and repacking per event would rebuild the container three times to the same end.
§Errors
Where the write-back failed. The session stays open: concept 6.2 puts the close at the user’s hand, and a failed save is a reason to tell them rather than to give up on the container.
Sourcepub fn save_if_changed(&mut self) -> Result<bool, Error>
pub fn save_if_changed(&mut self) -> Result<bool, Error>
Write the content file back, unless it already matches what the container holds.
Asked of the bytes rather than of the events. One save arrives as
several events — a temporary sibling, a rename, a metadata touch — and
they do not reliably land in one drain, so counting events makes the
number of repacks a function of how busy the machine is. A quiet period
before repacking would trade that for latency on every save and still
only make the guess better. recover answers the real question by
comparing against the CRC-32 the container already records (concept
6.3), so a redundant event costs one comparison instead of one rebuild.
Only the two quiet states are silent. An earlier version returned
nothing to do for every state that was not Edited, which meant a
container deleted or replaced underneath a live session stopped it
saving without saying anything — the user edits, nothing is written, and
no error appears. Those states go to the write-back to be refused and
reported, which is where the refusal belongs anyway.
§Errors
Where the write-back failed, or cannot be attempted at all.
Sourcepub fn close(self) -> Result<Closed, Error>
pub fn close(self) -> Result<Closed, Error>
Close the session: catch up on the watch, then clean up.
Concept 6.2’s question — write it back anyway? — is the caller’s, and
so is the answer: it asks, and calls
save_if_changed if the answer is yes. This
used to take a bool and repack unconditionally on it, which rebuilt
the container even when the content file matched it byte for byte, and
rebuilt it twice when the final pump had just done so.
§Errors
Where the final catch-up write-back failed, in which case nothing is removed and the session stays recoverable.