pub struct FileOperation<T> { /* private fields */ }Expand description
The result of a command sent to a player’s or recorder’s thread.
Like an async fn, this future submits no work until its first poll. Call
submit to submit it immediately instead. Queue admission
and operation deadlines start at submission, including any time spent queued.
Dropping an unsubmitted future does nothing. After submission, dropping an
ordinary command before it begins cancels it; once it has begun, dropping
only discards the result. Dropping a creation operation before receiving
its handle never waits for owner shutdown, including after creation has
completed. Submitted requests to stop, finish, close or abandon run
even if their future is dropped, as those methods say. A last-handle drop
waits for cleanup unless a submitted close or abandon still has a live future to report
completion. Dropping that close future restores the blocking drop guarantee.
An unsubmitted command does not keep an existing player or recorder alive.
Dropping the last handle still shuts down the owner as that handle documents;
later ordinary submissions fail with StateConflict::Closed. Closing remains
idempotent.
§The command queue
A handle’s commands wait in a queue of
AsyncFileOptions::command_capacity places, and a command submitted to a
full queue fails at submission with Error::QueueFull and
QueueLimit::FileCommands. A request to stop is one too
(AsyncFilePlayer::stop, AsyncFileRecorder::request_stop and
AsyncFileRecorder::finish), with one exception, so that a stop is not
lost for want of room: when the queue is full, one request to stop is
accepted beyond it. While that one waits, a further request to stop is
refused like any other command, so the queue never holds more than its
capacity and one. close does not use the
queue.
Recorder finish and wait_for_finish submissions also share an independent
budget of command_capacity pending waits. Their waiter place lasts through
queueing, registration and settlement; their command place is released when
the command starts. A full waiter budget refuses the submission with
QueueLimit::FileFinishWaits before it enters the queue. It does not use
command places, including the reserved stop place. Closed/failed owners and
invalid timeouts take precedence; when both budgets are full,
QueueLimit::FileCommands takes precedence. Close and abandon bypass both
budgets.
§Errors
Besides the operation’s own errors, every operation fails with
Error::QueueFull and QueueLimit::FileCommands when the queue
refuses it, as described above, and can fail with
Error::InvalidState: with StateConflict::Closed when the handle has
been closed or its thread stopped normally before carrying the
operation out, and with StateConflict::OwnerFailed when that thread failed
instead. Once the thread has failed, the operation it was running, every
operation queued behind it and every later one report
StateConflict::OwnerFailed, never StateConflict::Closed.
A submitted finish or wait, including one still queued, is settled with
the evidence gathered by a concurrent close. It reports Closed only when
that close ends its finalization budget without a settled session outcome.
§Panics
Polling again after completion panics.
Implementations§
Source§impl<T> FileOperation<T>
impl<T> FileOperation<T>
Sourcepub fn submit(self) -> Self
pub fn submit(self) -> Self
Submit this operation immediately, without waiting for its first poll.
Submission never waits for the SDK. It checks queue admission and starts the operation’s deadline now. Await the returned future to receive the result. Dropping it cancels an ordinary command that has not started; submitted stop, finish, close and abandon requests continue even when dropped.
For example, drop(recorder.request_stop().submit()) explicitly asks the
recorder to stop without waiting for its result. Merely dropping
recorder.request_stop() leaves the recorder running.