Skip to main content

FileOperation

Struct FileOperation 

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

Source

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.

Trait Implementations§

Source§

impl<T> Debug for FileOperation<T>

Source§

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

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

impl<T> Drop for FileOperation<T>

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
Source§

impl<T> Future for FileOperation<T>

Source§

type Output = Result<T, Error>

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Source§

impl<T> Unpin for FileOperation<T>

Auto Trait Implementations§

§

impl<T> !Freeze for FileOperation<T>

§

impl<T> RefUnwindSafe for FileOperation<T>

§

impl<T> Send for FileOperation<T>
where T: Send,

§

impl<T> Sync for FileOperation<T>
where T: Send,

§

impl<T> UnsafeUnpin for FileOperation<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for FileOperation<T>

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.

§

impl<F> FutureExt for F
where F: Future + ?Sized,

§

fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output>
where Self: Unpin,

A convenience for calling Future::poll() on !Unpin types.
§

fn or<F>(self, other: F) -> Or<Self, F> ⓘ
where Self: Sized, F: Future<Output = Self::Output>,

Returns the result of self or other future, preferring self if both are ready. Read more
§

fn race<F>(self, other: F) -> Race<Self, F> ⓘ
where Self: Sized, F: Future<Output = Self::Output>,

Returns the result of self or other future, with no preference if both are ready. Read more
§

fn catch_unwind(self) -> CatchUnwind<Self> ⓘ
where Self: Sized + UnwindSafe,

Catches panics while polling the future. Read more
§

fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
where Self: Sized + Send + 'a,

Boxes the future and changes its type to dyn Future + Send + 'a. Read more
§

fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>
where Self: Sized + 'a,

Boxes the future and changes its type to dyn Future + 'a. 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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
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.
§

impl<F, T, E> TryFuture for F
where F: Future<Output = Result<T, E>> + ?Sized,

§

type Ok = T

The type of successful values yielded by this future
§

type Error = E

The type of failures yielded by this future
§

fn try_poll( self: Pin<&mut F>, cx: &mut Context<'_>, ) -> Poll<<F as Future>::Output>

Poll this TryFuture as if it were a Future. Read more
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.