AsyncSCContentSharingPicker

Struct AsyncSCContentSharingPicker 

Source
pub struct AsyncSCContentSharingPicker;
Expand description

Async wrapper for SCContentSharingPicker (macOS 14.0+)

Provides async methods to show the system content sharing picker UI. Executor-agnostic - works with any async runtime.

§Examples

use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;

async fn pick_content() {
    let config = SCContentSharingPickerConfiguration::new();
    match AsyncSCContentSharingPicker::show(&config).await {
        SCPickerOutcome::Picked(result) => {
            let (width, height) = result.pixel_size();
            let filter = result.filter();
            println!("Selected content: {}x{}", width, height);
        }
        SCPickerOutcome::Cancelled => println!("User cancelled"),
        SCPickerOutcome::Error(e) => eprintln!("Error: {}", e),
    }
}

Implementations§

Source§

impl AsyncSCContentSharingPicker

Source

pub fn show(config: &SCContentSharingPickerConfiguration) -> AsyncPickerFuture

Show the picker UI asynchronously and return SCPickerResult with filter and metadata

This is the main API - use when you need content dimensions or want to build custom filters. The picker UI will be shown on the main thread, and the future will resolve when the user makes a selection or cancels.

§Example
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;

async fn example() {
    let config = SCContentSharingPickerConfiguration::new();
    if let SCPickerOutcome::Picked(result) = AsyncSCContentSharingPicker::show(&config).await {
        let (width, height) = result.pixel_size();
        let filter = result.filter();
    }
}
Source

pub fn show_filter( config: &SCContentSharingPickerConfiguration, ) -> AsyncPickerFilterFuture

Show the picker UI asynchronously and return an SCContentFilter directly

This is the simple API - use when you just need the filter without metadata.

§Example
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;

async fn example() {
    let config = SCContentSharingPickerConfiguration::new();
    if let SCPickerFilterOutcome::Filter(filter) = AsyncSCContentSharingPicker::show_filter(&config).await {
        // Use filter with SCStream
    }
}
Source

pub fn show_for_stream( config: &SCContentSharingPickerConfiguration, stream: &SCStream, ) -> AsyncPickerFuture

Show the picker UI for an existing stream to change source while capturing

Use this when you have an active SCStream and want to let the user select a new content source. The result can be used with stream.update_content_filter().

§Example
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;
use screencapturekit::stream::SCStream;
use screencapturekit::stream::configuration::SCStreamConfiguration;
use screencapturekit::stream::content_filter::SCContentFilter;
use screencapturekit::shareable_content::SCShareableContent;

async fn example() -> Option<()> {
    let content = SCShareableContent::get().ok()?;
    let displays = content.displays();
    let display = displays.first()?;
    let filter = SCContentFilter::create().with_display(display).with_excluding_windows(&[]).build();
    let stream_config = SCStreamConfiguration::new();
    let stream = SCStream::new(&filter, &stream_config);

    // When stream is active and user wants to change source
    let config = SCContentSharingPickerConfiguration::new();
    if let SCPickerOutcome::Picked(result) = AsyncSCContentSharingPicker::show_for_stream(&config, &stream).await {
        // Use result.filter() with stream.update_content_filter()
        let _ = result.filter();
    }
    Some(())
}

Trait Implementations§

Source§

impl Clone for AsyncSCContentSharingPicker

Source§

fn clone(&self) -> AsyncSCContentSharingPicker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AsyncSCContentSharingPicker

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for AsyncSCContentSharingPicker

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.