Skip to main content

SCContentFilterBuilder

Struct SCContentFilterBuilder 

Source
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

Source

pub fn with_display(self, display: &SCDisplay) -> Self

Set the display to capture

Source

pub fn with_window(self, window: &SCWindow) -> Self

Set the window to capture

Source

pub fn with_excluding_windows(self, windows: &[&SCWindow]) -> Self

Exclude specific windows from the display capture

Source

pub fn with_including_windows(self, windows: &[&SCWindow]) -> Self

Include only specific windows in the display capture

Source

pub fn with_including_applications( self, applications: &[&SCRunningApplication], excepting_windows: &[&SCWindow], ) -> Self

Include specific applications and optionally except certain windows

Source

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.

Source

pub fn with_include_menu_bar(self, include: bool) -> Self

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.

Source

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.

Trait Implementations§

Source§

impl Debug for SCContentFilterBuilder

Source§

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

Formats the value using the given formatter. 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.