Skip to main content

Opened

Struct Opened 

Source
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: Mark

What the platform recorded about where the container came from, carried onto the content file.

Implementations§

Source§

impl Opened

Source

pub fn session(&self) -> &Session

The session on disk.

Source

pub fn content_path(&self) -> PathBuf

Where the content file was put.

Source

pub fn saw_a_change(&self) -> bool

Whether the content file has been seen to change since the session opened.

Source

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.

Source

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.

Source

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.

Source

pub fn wait_and_pump(&mut self, within: Duration) -> Result<bool, Error>

Wait up to within for something to happen, then pump.

§Errors

As pump.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more