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
impl AsyncFileRecorder
Sourcepub fn create(
api: &FileApi,
options: &FileRecorderOptions,
) -> FileOperation<Self> ⓘ
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.
Sourcepub fn create_with_options(
api: &FileApi,
options: &FileRecorderOptions,
asynchronous: &AsyncFileOptions,
) -> FileOperation<Self> ⓘ
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.
Sourcepub fn start(
&self,
target: &RecordingTarget,
timecode: RecordingTimecode,
) -> FileOperation<u64> ⓘ
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.
Sourcepub fn request_stop(&self) -> FileOperation<StopRequest> ⓘ
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.
Sourcepub fn finish(&self, timeout: Duration) -> FileOperation<FinishStatus> ⓘ
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.
Sourcepub fn wait_for_finish(
&self,
timeout: Duration,
) -> FileOperation<Option<SessionEnd>> ⓘ
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.
Sourcepub fn reset(
&self,
options: &FileRecorderOptions,
) -> FileOperation<RecordingReport> ⓘ
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.
Sourcepub fn next_event(&self, timeout: Duration) -> FileEventFuture<RecorderEvent> ⓘ
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.
Sourcepub fn dropped_event_count(&self) -> FileOperation<u64> ⓘ
pub fn dropped_event_count(&self) -> FileOperation<u64> ⓘ
How many events the SDK discarded before the recorder’s thread took them.
Sourcepub fn notification_dropped_count(&self) -> u64
pub fn notification_dropped_count(&self) -> u64
How many events this handle’s own queue discarded because
next_event did not keep up.
Sourcepub fn state(&self) -> FileOperation<RecorderState> ⓘ
pub fn state(&self) -> FileOperation<RecorderState> ⓘ
Where the recorder is in its session.
Sourcepub fn report(&self) -> FileOperation<RecordingReport> ⓘ
pub fn report(&self) -> FileOperation<RecordingReport> ⓘ
What the recorder’s events have shown about the current session.
Sourcepub fn is_recording(&self) -> FileOperation<bool> ⓘ
pub fn is_recording(&self) -> FileOperation<bool> ⓘ
Whether the SDK is recording or waiting for frames.
Sourcepub fn set_source(&self, source: &SourceSpec) -> FileOperation<()> ⓘ
pub fn set_source(&self, source: &SourceSpec) -> FileOperation<()> ⓘ
Switch to recording another source; see FileRecorder::set_source.
Sourcepub fn last_accepted_source(&self) -> FileOperation<Option<SourceSpec>> ⓘ
pub fn last_accepted_source(&self) -> FileOperation<Option<SourceSpec>> ⓘ
The source the SDK accepted last; see
FileRecorder::last_accepted_source.
Sourcepub fn reported_current_file(&self) -> FileOperation<Option<EventText>> ⓘ
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.
Sourcepub fn rollover(&self, target: &RecordingTarget) -> FileOperation<()> ⓘ
pub fn rollover(&self, target: &RecordingTarget) -> FileOperation<()> ⓘ
Close the current file and continue in a new one; see
FileRecorder::rollover.
Sourcepub fn inject_metadata<S: MetadataSource + ?Sized>(
&self,
metadata: &S,
) -> FileOperation<()> ⓘ
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.
Sourcepub fn stats(&self) -> FileOperation<Option<RecorderStats>> ⓘ
pub fn stats(&self) -> FileOperation<Option<RecorderStats>> ⓘ
The recorder’s running counters.
Sourcepub fn source_format(&self) -> FileOperation<Option<SourceFormat>> ⓘ
pub fn source_format(&self) -> FileOperation<Option<SourceFormat>> ⓘ
The format of the source, once the recorder has seen audio or video.
Sourcepub fn abandon(&self) -> FileOperation<RecordingReport> ⓘ
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.
Sourcepub fn close(&self) -> FileOperation<()> ⓘ
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.