pub struct SCContentFilterBuilder { /* private fields */ }Expand description
Builder for creating SCContentFilter instances
§Examples
use screencapturekit::prelude::*;
let content = SCShareableContent::get()?;
let display = &content.displays()[0];
// Capture entire display
let filter = SCContentFilter::create()
.with_display(display)
.with_excluding_windows(&[])
.build()?;
// Capture with specific windows excluded
let window = &content.windows()[0];
let filter = SCContentFilter::create()
.with_display(display)
.with_excluding_windows(&[window])
.build()?;
// Capture specific window
let filter = SCContentFilter::create()
.with_window(window)
.build()?;Implementations§
Source§impl SCContentFilterBuilder
impl SCContentFilterBuilder
Sourcepub fn with_display(self, display: &SCDisplay) -> Self
pub fn with_display(self, display: &SCDisplay) -> Self
Set the display to capture
Sourcepub fn with_window(self, window: &SCWindow) -> Self
pub fn with_window(self, window: &SCWindow) -> Self
Set the window to capture
Sourcepub fn with_excluding_windows(self, windows: &[&SCWindow]) -> Self
pub fn with_excluding_windows(self, windows: &[&SCWindow]) -> Self
Exclude specific windows from the display capture
Sourcepub fn with_including_windows(self, windows: &[&SCWindow]) -> Self
pub fn with_including_windows(self, windows: &[&SCWindow]) -> Self
Include only specific windows in the display capture
Sourcepub fn with_including_applications(
self,
applications: &[&SCRunningApplication],
excepting_windows: &[&SCWindow],
) -> Self
pub fn with_including_applications( self, applications: &[&SCRunningApplication], excepting_windows: &[&SCWindow], ) -> Self
Include specific applications and optionally except certain windows
Sourcepub fn with_excluding_applications(
self,
applications: &[&SCRunningApplication],
excepting_windows: &[&SCWindow],
) -> Self
pub fn with_excluding_applications( self, applications: &[&SCRunningApplication], excepting_windows: &[&SCWindow], ) -> Self
Exclude specific applications and optionally except certain windows
Captures everything on the display except the specified applications.
Windows in excepting_windows will still be captured even if their
owning application is excluded.
Include or exclude the menu bar in display capture (macOS 14.2+)
This is the only way to set Apple’s SCContentFilter.includeMenuBar:
the built filter is immutable, so the value is applied here while the
underlying object is still uniquely owned by the builder (see the
SCContentFilter docs for why a post-construction setter would be
unsound).
Leaving it unset keeps Apple’s per-constructor default — true for
display-excluding filters, false for display-including ones. The
property has no effect on desktop-independent window filters.
Sourcepub fn build(self) -> SCResult<SCContentFilter>
pub fn build(self) -> SCResult<SCContentFilter>
Build the content filter.
§Errors
Returns SCError::InvalidConfiguration if neither .with_display() nor
.with_window() was called before building, and
SCError::FeatureNotAvailable if .with_include_menu_bar() was called
on a system older than macOS 14.2.