StreamCallbacks

Struct StreamCallbacks 

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

Builder for closure-based stream delegate

Provides a convenient way to create a stream delegate using closures instead of implementing the SCStreamDelegateTrait trait.

§Examples

use screencapturekit::prelude::*;
use screencapturekit::stream::delegate_trait::StreamCallbacks;


// Create delegate with multiple callbacks
let delegate = StreamCallbacks::new()
    .on_stop(|error| {
        if let Some(e) = error {
            eprintln!("Stream stopped with error: {}", e);
        } else {
            println!("Stream stopped normally");
        }
    })
    .on_error(|error| eprintln!("Stream error: {}", error))
    .on_active(|| println!("Stream became active"))
    .on_inactive(|| println!("Stream became inactive"));

let stream = SCStream::new_with_delegate(&filter, &config, delegate);

Implementations§

Source§

impl StreamCallbacks

Source

pub fn new() -> Self

Create a new empty callbacks builder

Source

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

Set the callback for when the stream stops

Source

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

Set the callback for when the stream encounters an error

Source

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

Set the callback for when the stream becomes active (macOS 15.2+)

Source

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

Set the callback for when the stream becomes inactive (macOS 15.2+)

Source

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

Set the callback for when video effects start (macOS 14.0+)

Source

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

Set the callback for when video effects stop (macOS 14.0+)

Trait Implementations§

Source§

impl Default for StreamCallbacks

Source§

fn default() -> Self

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

impl SCStreamDelegateTrait for StreamCallbacks

Source§

fn stream_did_stop(&self, error: Option<String>)

Called when stream stops Read more
Source§

fn did_stop_with_error(&self, error: SCError)

Called when stream stops with an error
Source§

fn stream_did_become_active(&self)

Called when the stream becomes active (macOS 15.2+) Read more
Source§

fn stream_did_become_inactive(&self)

Called when the stream becomes inactive (macOS 15.2+) Read more
Source§

fn output_video_effect_did_start_for_stream(&self)

Called when video effects start (macOS 14.0+) Read more
Source§

fn output_video_effect_did_stop_for_stream(&self)

Called when video effects stop (macOS 14.0+) 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> 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.