Skip to content

Commit e862352

Browse files
committed
docs: update API examples to use builder() pattern
- Update all documentation examples to use SCStreamConfiguration::builder() and SCContentFilter::builder() instead of deprecated build() - Fix doc examples to use new chainable setter pattern (returns Self) - Add backticks to module-level doc comments for clippy::doc_markdown
1 parent 55981c7 commit e862352

File tree

15 files changed

+68
-61
lines changed

15 files changed

+68
-61
lines changed

src/async_api.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Async API for ScreenCaptureKit
1+
//! Async API for `ScreenCaptureKit`
22
//!
33
//! This module provides async versions of operations when the `async` feature is enabled.
44
//! The async API is **executor-agnostic** and works with any async runtime (Tokio, async-std, smol, etc.).
@@ -258,8 +258,11 @@ unsafe impl Sync for AsyncSampleSender {}
258258
///
259259
/// let content = AsyncSCShareableContent::get().await?;
260260
/// let display = &content.displays()[0];
261-
/// let filter = SCContentFilter::build().display(display).exclude_windows(&[]).build();
262-
/// let config = SCStreamConfiguration::build();
261+
/// let filter = SCContentFilter::builder().display(display).exclude_windows(&[]).build();
262+
/// let config = SCStreamConfiguration::builder()
263+
/// .width(1920)
264+
/// .height(1080)
265+
/// .build();
263266
///
264267
/// let stream = AsyncSCStream::new(&filter, &config, 30, SCStreamOutputType::Screen);
265268
/// stream.start_capture()?;

src/recording_output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! SCRecordingOutput - Direct video file recording
1+
//! `SCRecordingOutput` - Direct video file recording
22
//!
33
//! Available on macOS 15.0+
44
//! Provides direct encoding of screen capture to video files.

src/screenshot_manager.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ extern "C" fn buffer_callback(
6464
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
6565
/// let content = SCShareableContent::get()?;
6666
/// let display = &content.displays()[0];
67-
/// let filter = SCContentFilter::build().display(display).exclude_windows(&[]).build();
68-
/// let config = SCStreamConfiguration::build();
67+
/// let filter = SCContentFilter::builder().display(display).exclude_windows(&[]).build();
68+
/// let config = SCStreamConfiguration::builder().build();
6969
///
7070
/// let image = SCScreenshotManager::capture_image(&filter, &config)?;
7171
/// println!("Screenshot size: {}x{}", image.width(), image.height());
@@ -93,7 +93,7 @@ impl CGImage {
9393
/// # let content = SCShareableContent::get()?;
9494
/// # let display = &content.displays()[0];
9595
/// # let filter = SCContentFilter::build().display(display).exclude_windows(&[]).build();
96-
/// # let config = SCStreamConfiguration::build();
96+
/// # let config = SCStreamConfiguration::default();
9797
/// let image = SCScreenshotManager::capture_image(&filter, &config)?;
9898
/// let width = image.width();
9999
/// println!("Width: {}", width);
@@ -180,10 +180,11 @@ unsafe impl Sync for CGImage {}
180180
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
181181
/// let content = SCShareableContent::get()?;
182182
/// let display = &content.displays()[0];
183-
/// let filter = SCContentFilter::build().display(display).exclude_windows(&[]).build();
184-
/// let config = SCStreamConfiguration::build()
185-
/// .set_width(1920)?
186-
/// .set_height(1080)?;
183+
/// let filter = SCContentFilter::builder().display(display).exclude_windows(&[]).build();
184+
/// let config = SCStreamConfiguration::builder()
185+
/// .width(1920)
186+
/// .height(1080)
187+
/// .build();
187188
///
188189
/// let image = SCScreenshotManager::capture_image(&filter, &config)?;
189190
/// println!("Captured screenshot: {}x{}", image.width(), image.height());

src/stream/configuration/audio.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl SCStreamConfiguration {
1414
/// ```
1515
/// use screencapturekit::prelude::*;
1616
///
17-
/// let config = SCStreamConfiguration::build()
17+
/// let config = SCStreamConfiguration::default()
1818
/// .set_captures_audio(true);
1919
/// assert!(config.get_captures_audio());
2020
/// ```
@@ -41,7 +41,7 @@ impl SCStreamConfiguration {
4141
/// ```
4242
/// use screencapturekit::prelude::*;
4343
///
44-
/// let config = SCStreamConfiguration::build()
44+
/// let config = SCStreamConfiguration::default()
4545
/// .set_sample_rate(48000);
4646
/// assert_eq!(config.get_sample_rate(), 48000);
4747
/// ```
@@ -70,7 +70,7 @@ impl SCStreamConfiguration {
7070
/// ```
7171
/// use screencapturekit::prelude::*;
7272
///
73-
/// let config = SCStreamConfiguration::build()
73+
/// let config = SCStreamConfiguration::default()
7474
/// .set_channel_count(2); // Stereo
7575
/// assert_eq!(config.get_channel_count(), 2);
7676
/// ```
@@ -105,7 +105,7 @@ impl SCStreamConfiguration {
105105
/// ```rust,no_run
106106
/// use screencapturekit::prelude::*;
107107
///
108-
/// let config = SCStreamConfiguration::build()
108+
/// let config = SCStreamConfiguration::default()
109109
/// .set_captures_audio(true) // System audio
110110
/// .set_captures_microphone(true) // Microphone audio (macOS 15.0+)
111111
/// .set_sample_rate(48000)
@@ -134,7 +134,7 @@ impl SCStreamConfiguration {
134134
/// ```rust,no_run
135135
/// use screencapturekit::prelude::*;
136136
///
137-
/// let config = SCStreamConfiguration::build()
137+
/// let config = SCStreamConfiguration::default()
138138
/// .set_captures_audio(true)
139139
/// .set_excludes_current_process_audio(true); // Prevent feedback
140140
/// ```
@@ -164,7 +164,7 @@ impl SCStreamConfiguration {
164164
/// ```rust,no_run
165165
/// use screencapturekit::prelude::*;
166166
///
167-
/// let config = SCStreamConfiguration::build()
167+
/// let config = SCStreamConfiguration::default()
168168
/// .set_captures_microphone(true)
169169
/// .set_microphone_capture_device_id(Some("AppleHDAEngineInput:1B,0,1,0:1"));
170170
/// ```

src/stream/configuration/captured_elements.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl SCStreamConfiguration {
1313
/// ```
1414
/// use screencapturekit::prelude::*;
1515
///
16-
/// let config = SCStreamConfiguration::build()
16+
/// let config = SCStreamConfiguration::default()
1717
/// .set_shows_cursor(true);
1818
/// assert!(config.get_shows_cursor());
1919
/// ```
@@ -44,7 +44,7 @@ impl SCStreamConfiguration {
4444
/// ```
4545
/// use screencapturekit::prelude::*;
4646
///
47-
/// let config = SCStreamConfiguration::build()
47+
/// let config = SCStreamConfiguration::default()
4848
/// .set_width(1920)
4949
/// .set_height(1080)
5050
/// .set_captures_shadows_only(true); // Only capture shadows

src/stream/configuration/colors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl SCStreamConfiguration {
1414
/// ```
1515
/// use screencapturekit::stream::configuration::{SCStreamConfiguration, PixelFormat};
1616
///
17-
/// let config = SCStreamConfiguration::build()
17+
/// let config = SCStreamConfiguration::default()
1818
/// .set_pixel_format(PixelFormat::BGRA);
1919
/// ```
2020
pub fn set_pixel_format(self, pixel_format: PixelFormat) -> Self {

src/stream/configuration/dimensions.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl SCStreamConfiguration {
1717
/// ```
1818
/// use screencapturekit::prelude::*;
1919
///
20-
/// let config = SCStreamConfiguration::build()
20+
/// let config = SCStreamConfiguration::default()
2121
/// .set_width(1920);
2222
/// assert_eq!(config.get_width(), 1920);
2323
/// ```
@@ -37,7 +37,7 @@ impl SCStreamConfiguration {
3737
/// ```
3838
/// use screencapturekit::prelude::*;
3939
///
40-
/// let config = SCStreamConfiguration::build()
40+
/// let config = SCStreamConfiguration::default()
4141
/// .set_width(1920);
4242
/// assert_eq!(config.get_width(), 1920);
4343
/// ```
@@ -58,7 +58,7 @@ impl SCStreamConfiguration {
5858
/// ```
5959
/// use screencapturekit::prelude::*;
6060
///
61-
/// let config = SCStreamConfiguration::build()
61+
/// let config = SCStreamConfiguration::default()
6262
/// .set_height(1080);
6363
/// assert_eq!(config.get_height(), 1080);
6464
/// ```
@@ -78,7 +78,7 @@ impl SCStreamConfiguration {
7878
/// ```
7979
/// use screencapturekit::prelude::*;
8080
///
81-
/// let config = SCStreamConfiguration::build()
81+
/// let config = SCStreamConfiguration::default()
8282
/// .set_height(1080);
8383
/// assert_eq!(config.get_height(), 1080);
8484
/// ```
@@ -100,7 +100,7 @@ impl SCStreamConfiguration {
100100
/// ```
101101
/// use screencapturekit::prelude::*;
102102
///
103-
/// let config = SCStreamConfiguration::build()
103+
/// let config = SCStreamConfiguration::default()
104104
/// .set_scales_to_fit(true);
105105
/// assert!(config.get_scales_to_fit());
106106
/// ```
@@ -131,7 +131,7 @@ impl SCStreamConfiguration {
131131
///
132132
/// // Capture only top-left quarter of screen
133133
/// let rect = CGRect::new(0.0, 0.0, 960.0, 540.0);
134-
/// let config = SCStreamConfiguration::build()
134+
/// let config = SCStreamConfiguration::default()
135135
/// .set_source_rect(rect);
136136
/// ```
137137
pub fn set_source_rect(self, source_rect: CGRect) -> Self {
@@ -178,7 +178,7 @@ impl SCStreamConfiguration {
178178
///
179179
/// // Place captured content in top-left corner
180180
/// let rect = CGRect::new(0.0, 0.0, 640.0, 480.0);
181-
/// let config = SCStreamConfiguration::build()
181+
/// let config = SCStreamConfiguration::default()
182182
/// .set_destination_rect(rect);
183183
/// ```
184184
pub fn set_destination_rect(self, destination_rect: CGRect) -> Self {
@@ -225,7 +225,7 @@ impl SCStreamConfiguration {
225225
/// ```
226226
/// use screencapturekit::prelude::*;
227227
///
228-
/// let config = SCStreamConfiguration::build()
228+
/// let config = SCStreamConfiguration::default()
229229
/// .set_preserves_aspect_ratio(true);
230230
/// // Returns true on macOS 14.0+, false on older versions
231231
/// let _ = config.get_preserves_aspect_ratio();
@@ -272,7 +272,7 @@ impl SCStreamConfiguration {
272272
/// ```
273273
/// use screencapturekit::prelude::*;
274274
///
275-
/// let config = SCStreamConfiguration::build()
275+
/// let config = SCStreamConfiguration::default()
276276
/// .set_increase_resolution_for_retina_displays(true);
277277
/// // Note: Getter may not return the set value on all macOS versions
278278
/// let _ = config.get_increase_resolution_for_retina_displays();

src/stream/configuration/internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::fmt;
1111
/// ```
1212
/// use screencapturekit::stream::configuration::SCStreamConfiguration;
1313
///
14-
/// let config = SCStreamConfiguration::build()
14+
/// let config = SCStreamConfiguration::default()
1515
/// .set_width(1920)
1616
/// .set_height(1080);
1717
/// ```

src/stream/configuration/stream_properties.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl SCStreamConfiguration {
2929
/// ```rust,no_run
3030
/// use screencapturekit::prelude::*;
3131
///
32-
/// let config = SCStreamConfiguration::build()
32+
/// let config = SCStreamConfiguration::default()
3333
/// .set_stream_name(Some("MyApp-MainCapture"));
3434
/// ```
3535
pub fn set_stream_name(self, name: Option<&str>) -> Self {
@@ -81,7 +81,7 @@ impl SCStreamConfiguration {
8181
/// use screencapturekit::prelude::*;
8282
/// use screencapturekit::stream::configuration::stream_properties::SCCaptureDynamicRange;
8383
///
84-
/// let config = SCStreamConfiguration::build()
84+
/// let config = SCStreamConfiguration::default()
8585
/// .set_width(1920)
8686
/// .set_height(1080)
8787
/// .set_capture_dynamic_range(SCCaptureDynamicRange::HDRLocalDisplay);

src/stream/content_filter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! let display = &content.displays()[0];
1414
//!
1515
//! // Capture entire display
16-
//! let filter = SCContentFilter::build()
16+
//! let filter = SCContentFilter::builder()
1717
//! .display(display)
1818
//! .exclude_windows(&[])
1919
//! .build();
@@ -44,14 +44,14 @@ use crate::{
4444
/// let display = &content.displays()[0];
4545
///
4646
/// // Capture entire display
47-
/// let filter = SCContentFilter::build()
47+
/// let filter = SCContentFilter::builder()
4848
/// .display(display)
4949
/// .exclude_windows(&[])
5050
/// .build();
5151
///
5252
/// // Or capture a specific window
5353
/// let window = &content.windows()[0];
54-
/// let filter = SCContentFilter::build()
54+
/// let filter = SCContentFilter::builder()
5555
/// .window(window)
5656
/// .build();
5757
/// # Ok(())
@@ -209,20 +209,20 @@ unsafe impl Sync for SCContentFilter {}
209209
/// let display = &content.displays()[0];
210210
///
211211
/// // Capture entire display
212-
/// let filter = SCContentFilter::build()
212+
/// let filter = SCContentFilter::builder()
213213
/// .display(display)
214214
/// .exclude_windows(&[])
215215
/// .build();
216216
///
217217
/// // Capture with specific windows excluded
218218
/// let window = &content.windows()[0];
219-
/// let filter = SCContentFilter::build()
219+
/// let filter = SCContentFilter::builder()
220220
/// .display(display)
221221
/// .exclude_windows(&[window])
222222
/// .build();
223223
///
224224
/// // Capture specific window
225-
/// let filter = SCContentFilter::build()
225+
/// let filter = SCContentFilter::builder()
226226
/// .window(window)
227227
/// .build();
228228
/// # Ok(())

0 commit comments

Comments
 (0)