Skip to main content

DebouncedWriter

Struct DebouncedWriter 

Source
pub struct DebouncedWriter { /* private fields */ }
Expand description

Atomic, debounced single-file writer.

All writers in a process share one background I/O thread (see module docs). Each writer is identified by an opaque WriterId; dropping a writer synchronously flushes its pending payload before returning.

Implementations§

Source§

impl DebouncedWriter

Source

pub fn new(path: PathBuf, delay: Duration) -> Self

Create a writer that will atomically write to path, coalescing rapid schedule bursts inside delay.

delay = Duration::ZERO makes every schedule flush on the worker’s very next iteration — useful for tests.

Source

pub fn flush_now(&self) -> Result<(), FlushError>

Force any queued patches to disk synchronously. Returns Ok(()) if there was nothing queued.

Source

pub fn set_landed_sink(&self, sink: WriteLandedSink)

Register a sink for this writer’s successful-flush stamp (opt-in; a writer with none behaves exactly as today). May be called any time after construction — including after the writer has already flushed once, since the sink is only ever consulted on a future successful flush.

This is how a caller learns the real on-disk stamp resulting from its own debounced write, without guessing: apply() schedules a patch and returns before it lands, so only the worker thread — right after the write actually succeeds — knows the resulting (mtime, len). See WindowStateService::reload_from_disk for the consumer side (F11).

Source

pub fn path(&self) -> &Path

The destination path this writer flushes to.

Source

pub fn delay(&self) -> Duration

The debounce window configured at construction; Duration::ZERO means every scheduled payload is written on the worker’s next iteration (useful in tests).

Trait Implementations§

Source§

impl Debug for DebouncedWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for DebouncedWriter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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, 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.