pub struct Operation<T> { /* private fields */ }Expand description
A handle to a running long operation (Markdown/HTML import, DOCX export).
Provides typed access to progress, cancellation, and the result.
Progress events are also emitted via DocumentEvent::LongOperationProgress
and DocumentEvent::LongOperationFinished
for the callback/polling path.
Retrieve the result via wait() (blocking, consumes the handle)
or try_result() (non-blocking, can be called repeatedly).
Implementations§
Source§impl<T> Operation<T>
impl<T> Operation<T>
Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
The operation ID (for matching with DocumentEvent variants).
Sourcepub fn progress(&self) -> Option<(f64, String)>
pub fn progress(&self) -> Option<(f64, String)>
Get the current progress, if available.
Returns (percent, message) where percent is 0.0–100.0.
Sourcepub fn is_done(&self) -> bool
pub fn is_done(&self) -> bool
Returns true if the operation has finished (success or failure).
Reads the completion signal, not just the result slot: a cancelled or failed operation stores no result but is very much finished.
Sourcepub fn wait(self) -> Result<T>
pub fn wait(self) -> Result<T>
Block the calling thread until the operation completes and return the typed result. Consumes the handle.
The wait is signal-driven: the manager wakes it the moment the operation publishes completion, so a short operation costs only its own runtime. It previously re-checked on a 50 ms timer, which put a ~50 ms floor under every call however trivial the work — invisible for one import, but seconds of dead time for a caller loading documents in a loop.
A cancelled or failed operation now returns Err rather than blocking
forever: neither ever stores a result, so the old “loop until a result
appears” never terminated for them.
Sourcepub fn wait_timeout(self, timeout: Duration) -> Option<Result<T>>
pub fn wait_timeout(self, timeout: Duration) -> Option<Result<T>>
Block until the operation completes or the timeout expires.
Returns None if the timeout elapsed before the operation finished.
Like wait, this blocks on the completion signal rather
than a timer, so it returns as soon as the operation ends instead of on
the next 50 ms boundary.
Sourcepub fn try_result(&mut self) -> Option<Result<T>>
pub fn try_result(&mut self) -> Option<Result<T>>
Non-blocking: returns the result if the operation has completed,
None if still running. Can be called repeatedly.