SCRecordingOutputDelegate

Trait SCRecordingOutputDelegate 

Source
pub trait SCRecordingOutputDelegate: Send + 'static {
    // Provided methods
    fn recording_did_start(&self) { ... }
    fn recording_did_fail(&self, _error: String) { ... }
    fn recording_did_finish(&self) { ... }
}
Expand description

Delegate for recording output events

Implement this trait to receive notifications about recording lifecycle events.

§Examples

§Using a struct

use screencapturekit::recording_output::SCRecordingOutputDelegate;

struct MyRecordingDelegate;

impl SCRecordingOutputDelegate for MyRecordingDelegate {
    fn recording_did_start(&self) {
        println!("Recording started!");
    }
    fn recording_did_fail(&self, error: String) {
        eprintln!("Recording failed: {}", error);
    }
    fn recording_did_finish(&self) {
        println!("Recording finished!");
    }
}

§Using closures

Use RecordingCallbacks to create a delegate from closures:

use screencapturekit::recording_output::{
    SCRecordingOutput, SCRecordingOutputConfiguration, RecordingCallbacks
};
use std::path::Path;

let config = SCRecordingOutputConfiguration::new()
    .with_output_url(Path::new("/tmp/recording.mp4"));

let delegate = RecordingCallbacks::new()
    .on_start(|| println!("Started!"))
    .on_finish(|| println!("Finished!"))
    .on_fail(|e| eprintln!("Error: {}", e));

let recording = SCRecordingOutput::new_with_delegate(&config, delegate);

Provided Methods§

Source

fn recording_did_start(&self)

Called when recording starts successfully

Source

fn recording_did_fail(&self, _error: String)

Called when recording fails with an error

Source

fn recording_did_finish(&self)

Called when recording finishes successfully

Implementors§