pub struct AsyncSCScreenshotManager;Expand description
Async wrapper for SCScreenshotManager
Provides async methods for single-frame screenshot capture. Executor-agnostic - works with any async runtime.
Requires the macos_14_0 feature flag.
§Examples
use screencapturekit::async_api::{AsyncSCShareableContent, AsyncSCScreenshotManager};
use screencapturekit::stream::configuration::SCStreamConfiguration;
use screencapturekit::stream::content_filter::SCContentFilter;
let content = AsyncSCShareableContent::get().await?;
let display = &content.displays()[0];
let filter = SCContentFilter::create().with_display(display).with_excluding_windows(&[]).build();
let config = SCStreamConfiguration::new()
.with_width(1920)
.with_height(1080);
let image = AsyncSCScreenshotManager::capture_image(&filter, &config).await?;
println!("Screenshot: {}x{}", image.width(), image.height());Implementations§
Source§impl AsyncSCScreenshotManager
impl AsyncSCScreenshotManager
Sourcepub fn capture_image(
content_filter: &SCContentFilter,
configuration: &SCStreamConfiguration,
) -> AsyncScreenshotFuture<CGImage> ⓘ
pub fn capture_image( content_filter: &SCContentFilter, configuration: &SCStreamConfiguration, ) -> AsyncScreenshotFuture<CGImage> ⓘ
Capture a single screenshot as a CGImage asynchronously
§Errors
Returns an error if:
- Screen recording permission is not granted
- The capture fails for any reason
Sourcepub fn capture_sample_buffer(
content_filter: &SCContentFilter,
configuration: &SCStreamConfiguration,
) -> AsyncScreenshotFuture<CMSampleBuffer> ⓘ
pub fn capture_sample_buffer( content_filter: &SCContentFilter, configuration: &SCStreamConfiguration, ) -> AsyncScreenshotFuture<CMSampleBuffer> ⓘ
Capture a single screenshot as a CMSampleBuffer asynchronously
§Errors
Returns an error if:
- Screen recording permission is not granted
- The capture fails for any reason
Sourcepub fn capture_image_in_rect(rect: CGRect) -> AsyncScreenshotFuture<CGImage> ⓘ
pub fn capture_image_in_rect(rect: CGRect) -> AsyncScreenshotFuture<CGImage> ⓘ
Capture a screenshot of a specific screen region asynchronously (macOS 15.2+)
This method captures the content within the specified rectangle, which can span multiple displays.
§Arguments
rect- The rectangle to capture, in screen coordinates (points)
§Errors
Returns an error if:
- The system is not macOS 15.2+
- Screen recording permission is not granted
- The capture fails for any reason
Sourcepub fn capture_screenshot(
content_filter: &SCContentFilter,
configuration: &SCScreenshotConfiguration,
) -> AsyncScreenshotFuture<SCScreenshotOutput> ⓘ
pub fn capture_screenshot( content_filter: &SCContentFilter, configuration: &SCScreenshotConfiguration, ) -> AsyncScreenshotFuture<SCScreenshotOutput> ⓘ
Capture a screenshot with advanced configuration asynchronously (macOS 26.0+)
This method uses the new SCScreenshotConfiguration for more control
over the screenshot output, including HDR support and file saving.
§Arguments
content_filter- The content filter specifying what to captureconfiguration- The screenshot configuration
§Errors
Returns an error if the capture fails
Sourcepub fn capture_screenshot_in_rect(
rect: CGRect,
configuration: &SCScreenshotConfiguration,
) -> AsyncScreenshotFuture<SCScreenshotOutput> ⓘ
pub fn capture_screenshot_in_rect( rect: CGRect, configuration: &SCScreenshotConfiguration, ) -> AsyncScreenshotFuture<SCScreenshotOutput> ⓘ
Trait Implementations§
Source§impl Clone for AsyncSCScreenshotManager
impl Clone for AsyncSCScreenshotManager
Source§fn clone(&self) -> AsyncSCScreenshotManager
fn clone(&self) -> AsyncSCScreenshotManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more