Skip to main content

AsyncFileRecorder

Struct AsyncFileRecorder 

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

A FileRecorder on a thread of its own, driven through futures.

Clones share one recorder, whose events are pumped continuously, so its session report stays current without the caller polling.

§Finishing

Await finish and check for SessionEnd::Closed to know a recording is complete, then await close. Neither blocks the executor. Native event loss, unreadable lifecycle evidence or a file-tracking limit requires reset before another session can start. Closing then uses the remaining cleanup budget even if every known file closes; the indeterminate report remains unchanged. Evicted application event notifications do not make native file tracking incomplete.

§Dropping blocks

This applies after creation returns the handle. Dropping its creation operation before receiving the handle requests cleanup without waiting.

Dropping the last clone blocks the dropping thread until the recorder’s thread has finished. Its cleanup follows FileRecorderOptions::drop_wait. Await close to perform that cleanup without blocking the executor.

While a submitted close or abandon still has a live future, last-clone drop does not wait because that future reports completion. Dropping the future makes the last-clone drop wait for cleanup again. A last-clone drop performed by an executor callback on a File owner, timer or probe thread requests shutdown without waiting for finalization or destruction. Await close to observe cleanup completing.

Implementations§

Source§

impl AsyncFileRecorder

Source

pub fn create( api: &FileApi, options: &FileRecorderOptions, ) -> FileOperation<Self> ⓘ

Create a recorder with the default queue sizes.

The future fails as FileRecorder::new does, including with Error::InvalidInput for options that conflict. The options are only read, so they stay with the caller whatever the outcome. Options and the required File family are checked at submission, before an owner thread starts. Native creation runs on that thread.

§Errors

Those of FileRecorder::new, and Error::Io when the owner thread cannot be started.

Source

pub fn create_with_options( api: &FileApi, options: &FileRecorderOptions, asynchronous: &AsyncFileOptions, ) -> FileOperation<Self> ⓘ

Create a recorder with the given queue sizes.

The future fails as create does, and with Error::InvalidInput when a queue size is out of range. Queue sizes, options and the required File family are checked at submission, before an owner thread starts.

Source

pub fn start( &self, target: &RecordingTarget, timecode: RecordingTimecode, ) -> FileOperation<u64> ⓘ

Start a session; see FileRecorder::start. Generated starts carry a SessionTimecode, validated before queuing. Events left by an earlier refused start are delivered through next_event before the new session begins. A recording or stopping session returns StateConflict::PreviousSessionOpen. After it ends, see StateConflict::IncompleteFileTracking for when a new session requires a reset.

Source

pub fn request_stop(&self) -> FileOperation<StopRequest> ⓘ

Ask the SDK to stop the session. Once submitted by polling or calling FileOperation::submit, the request runs even if its future is dropped.

Source

pub fn finish(&self, timeout: Duration) -> FileOperation<FinishStatus> ⓘ

Stop the session and wait up to timeout for its last file to be closed; see FileRecorder::finish.

The wait starts on the first poll or explicit submission, including time the command spends queued. After submission, dropping the future ends the wait but not the stop: the recorder keeps stopping and its events keep being pumped, and wait_for_finish can pick the wait up again. While waiting for closure, the owner continues running other commands and waits from every clone between event bursts. A native call such as the stop itself may still block that thread. Each concurrent wait keeps its own submission deadline and observes the same session report. Submitted finish and condition waits share a separate budget of AsyncFileOptions::command_capacity places. When it is full, a new submission fails with Error::QueueFull and QueueLimit::FileFinishWaits before requesting a stop. Drop or await existing waits to restore admission; cancellation is reclaimed by the owner. Ordinary commands and explicit stop requests remain available.

If another clone closes the recorder during the wait, the FileRecorderOptions::drop_wait deadline can end the wait early. Closure established in that time is reported normally; an unsettled session reports StateConflict::Closed instead of FinishStatus::TimedOut, because the recorder is being destroyed and cannot be waited on again.

Events taken during the wait go to next_event. An unreadable format is withheld through RecorderEvent::source_format while the event is delivered. A whole-event layout or type mismatch is delivered as Error::UnexpectedSdkResult; it does not end the wait.

§Errors

Those of FileRecorder::finish, and those every FileOperation can fail with.

Source

pub fn wait_for_finish( &self, timeout: Duration, ) -> FileOperation<Option<SessionEnd>> ⓘ

Wait up to timeout for a stopping session to end; see FileRecorder::wait_for_finish.

Returns None when the timeout expires, or Some with SessionEnd::Closed or SessionEnd::Indeterminate when the session ends. The current report remains available through report, including after a timeout.

Events taken during the wait are delivered as by finish; other commands and waits continue running. A concurrent close bounds the wait and can return StateConflict::Closed on the same terms as finish. It shares finish’s independent pending-wait limit and can report Error::QueueFull with QueueLimit::FileFinishWaits.

§Errors

Those of FileRecorder::wait_for_finish, and those every FileOperation can fail with.

Source

pub fn reset( &self, options: &FileRecorderOptions, ) -> FileOperation<RecordingReport> ⓘ

Replace the native recorder after abandoning its old session; see FileRecorder::reset. Queued events already delivered to this worker’s event stream remain available to the caller. A successful reset ends pending finish waits for the old recorder with StateConflict::Closed; a failed reset leaves them waiting on the original session. Options are checked at submission, before waiting in the command queue.

Source

pub fn next_event(&self, timeout: Duration) -> FileEventFuture<RecorderEvent> ⓘ

Wait up to timeout for the recorder’s next event. Dropping the future does not affect the recording.

Source

pub fn dropped_event_count(&self) -> FileOperation<u64> ⓘ

How many events the SDK discarded before the recorder’s thread took them.

Source

pub fn notification_dropped_count(&self) -> u64

How many events this handle’s own queue discarded because next_event did not keep up.

Source

pub fn state(&self) -> FileOperation<RecorderState> ⓘ

Where the recorder is in its session.

Source

pub fn report(&self) -> FileOperation<RecordingReport> ⓘ

What the recorder’s events have shown about the current session.

Source

pub fn is_recording(&self) -> FileOperation<bool> ⓘ

Whether the SDK is recording or waiting for frames.

Source

pub fn set_source(&self, source: &SourceSpec) -> FileOperation<()> ⓘ

Switch to recording another source; see FileRecorder::set_source.

Source

pub fn last_accepted_source(&self) -> FileOperation<Option<SourceSpec>> ⓘ

The source the SDK accepted last; see FileRecorder::last_accepted_source.

Source

pub fn reported_current_file(&self) -> FileOperation<Option<EventText>> ⓘ

The most recently opened file still retained in the file tracker; see FileRecorder::reported_current_file for incomplete-tracking limits.

Source

pub fn rollover(&self, target: &RecordingTarget) -> FileOperation<()> ⓘ

Close the current file and continue in a new one; see FileRecorder::rollover.

Source

pub fn inject_metadata<S: MetadataSource + ?Sized>( &self, metadata: &S, ) -> FileOperation<()> ⓘ

Write a metadata frame into the recording at its current position; see FileRecorder::inject_metadata.

Copies the source’s text and timecode when this method is called, retaining the copy until the deferred worker command runs or is discarded. Accepts owned and captured metadata without retaining a native frame or borrowing the source through the command’s lifetime.

Source

pub fn stats(&self) -> FileOperation<Option<RecorderStats>> ⓘ

The recorder’s running counters.

Source

pub fn source_format(&self) -> FileOperation<Option<SourceFormat>> ⓘ

The format of the source, once the recorder has seen audio or video.

Source

pub fn abandon(&self) -> FileOperation<RecordingReport> ⓘ

Stop and destroy the recorder without waiting for the SDK to finalize an open file, returning the last known session report after destruction. The file of an unfinished session may be left truncated.

Like close, this affects every clone, bypasses the command queue and runs after submission even if its future is dropped. A close pending when abandon is submitted completes with the same shutdown; later operations fail with StateConflict::Closed. An already running native call cannot be interrupted.

§Errors

Error::InvalidState with StateConflict::OwnerFailed when the object’s thread failed.

Source

pub fn close(&self) -> FileOperation<()> ⓘ

Stop an open session, destroy the recorder and end its thread, for every clone of this handle.

Shutdown follows FileRecorderOptions::drop_wait. A submitted finish or wait_for_finish keeps its own earlier deadline. The future completes when the SDK has destroyed the recorder. Await finish first to learn whether the SDK confirmed closure. Once submitted by polling or calling FileOperation::submit, the close runs even if its future is dropped. Closing again, from this or another clone, while or after it runs completes at the same time, with the same outcome; later operations fail with StateConflict::Closed, and dropping the clones afterwards does not block. It does not wait in the command queue, so a full queue never refuses it.

§Errors

Error::InvalidState with StateConflict::OwnerFailed when the object’s thread failed.

Trait Implementations§

Source§

impl Clone for AsyncFileRecorder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AsyncFileRecorder

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
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.