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
impl StreamCallbacks
Sourcepub fn on_error<F>(self, f: F) -> Self
pub fn on_error<F>(self, f: F) -> Self
Set the callback for when the stream encounters an error
Sourcepub fn on_active<F>(self, f: F) -> Self
pub fn on_active<F>(self, f: F) -> Self
Set the callback for when the stream becomes active (macOS 15.2+)
Sourcepub fn on_inactive<F>(self, f: F) -> Self
pub fn on_inactive<F>(self, f: F) -> Self
Set the callback for when the stream becomes inactive (macOS 15.2+)
Sourcepub fn on_video_effect_start<F>(self, f: F) -> Self
pub fn on_video_effect_start<F>(self, f: F) -> Self
Set the callback for when video effects start (macOS 14.0+)
Sourcepub fn on_video_effect_stop<F>(self, f: F) -> Self
pub fn on_video_effect_stop<F>(self, f: F) -> Self
Set the callback for when video effects stop (macOS 14.0+)
Trait Implementations§
Source§impl Default for StreamCallbacks
impl Default for StreamCallbacks
Source§impl SCStreamDelegateTrait for StreamCallbacks
impl SCStreamDelegateTrait for StreamCallbacks
Source§fn did_stop_with_error(&self, error: SCError)
fn did_stop_with_error(&self, error: SCError)
Called when stream stops with an error
Source§fn stream_did_become_active(&self)
fn stream_did_become_active(&self)
Called when the stream becomes active (macOS 15.2+) Read more
Source§fn stream_did_become_inactive(&self)
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)
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)
fn output_video_effect_did_stop_for_stream(&self)
Called when video effects stop (macOS 14.0+) Read more
Auto Trait Implementations§
impl Freeze for StreamCallbacks
impl !RefUnwindSafe for StreamCallbacks
impl Send for StreamCallbacks
impl !Sync for StreamCallbacks
impl Unpin for StreamCallbacks
impl !UnwindSafe for StreamCallbacks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more