RecordingCallbacks

Struct RecordingCallbacks 

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

Builder for closure-based recording delegate

Provides a convenient way to create a recording delegate using closures instead of implementing the SCRecordingOutputDelegate trait.

§Examples

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

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

// Create delegate with all callbacks
let delegate = RecordingCallbacks::new()
    .on_start(|| println!("Recording started!"))
    .on_finish(|| println!("Recording finished!"))
    .on_fail(|error| eprintln!("Recording failed: {}", error));

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

// Or just handle specific events
let delegate = RecordingCallbacks::new()
    .on_fail(|error| eprintln!("Error: {}", error));

Implementations§

Source§

impl RecordingCallbacks

Source

pub fn new() -> Self

Create a new empty callbacks builder

Source

pub fn on_start<F>(self, f: F) -> Self
where F: Fn() + Send + 'static,

Set the callback for when recording starts

Source

pub fn on_fail<F>(self, f: F) -> Self
where F: Fn(String) + Send + 'static,

Set the callback for when recording fails

Source

pub fn on_finish<F>(self, f: F) -> Self
where F: Fn() + Send + 'static,

Set the callback for when recording finishes

Trait Implementations§

Source§

impl Debug for RecordingCallbacks

Source§

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

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

impl Default for RecordingCallbacks

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl SCRecordingOutputDelegate for RecordingCallbacks

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

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.