Skip to content

Commit a47cab3

Browse files
committed
refactor: rename SCContentFilter::build() to builder() for consistency
- Add SCContentFilter::builder() as the primary API - Deprecate SCContentFilter::build() - Update all examples and README to use builder()
1 parent ce22e21 commit a47cab3

10 files changed

Lines changed: 22 additions & 15 deletions

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Capture screen content, windows, and applications with high performance and low
1717
- 🎥 **Screen & Window Capture** - Capture displays, windows, or specific applications
1818
- 🔊 **Audio Capture** - Capture system audio and microphone input
1919
-**Real-time Processing** - High-performance frame callbacks with custom dispatch queues
20-
- 🏗️ **Builder Pattern API** - Clean, type-safe configuration with `::builder()` and `::build()`
20+
- 🏗️ **Builder Pattern API** - Clean, type-safe configuration with `::builder()`
2121
- 🔄 **Async Support** - Runtime-agnostic async API (works with Tokio, async-std, smol, etc.)
2222
- 🎨 **IOSurface Access** - Zero-copy GPU texture access for Metal/OpenGL
2323
- 🛡️ **Memory Safe** - Proper reference counting and leak-free by design
@@ -67,7 +67,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6767
let display = &content.displays()[0];
6868

6969
// Configure capture
70-
let filter = SCContentFilter::build()
70+
let filter = SCContentFilter::builder()
7171
.display(display)
7272
.exclude_windows(&[])
7373
.build();
@@ -104,7 +104,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
104104
let display = &content.displays()[0];
105105

106106
// Create filter and config
107-
let filter = SCContentFilter::build()
107+
let filter = SCContentFilter::builder()
108108
.display(display)
109109
.exclude_windows(&[])
110110
.build();
@@ -145,7 +145,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
145145
.ok_or("Safari window not found")?;
146146

147147
// Capture window with audio
148-
let filter = SCContentFilter::build()
148+
let filter = SCContentFilter::builder()
149149
.window(window)
150150
.build();
151151

@@ -173,7 +173,7 @@ All types use a consistent builder pattern with a final `.build()` call:
173173

174174
```rust
175175
// Content filters
176-
let filter = SCContentFilter::build()
176+
let filter = SCContentFilter::builder()
177177
.display(&display)
178178
.exclude_windows(&windows)
179179
.build();
@@ -401,7 +401,7 @@ screencapturekit/
401401

402402
Contributions welcome! Please:
403403

404-
1. Follow existing code patterns (builder pattern with `::builder()` and `::build()`)
404+
1. Follow existing code patterns (builder pattern with `::builder()`)
405405
2. Add tests for new functionality
406406
3. Run `cargo test` and `cargo clippy`
407407
4. Update documentation

examples/01_basic_capture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3737
println!("Display: {}x{}", display.width(), display.height());
3838

3939
// 2. Create content filter (what to capture)
40-
let filter = SCContentFilter::build()
40+
let filter = SCContentFilter::builder()
4141
.display(&display)
4242
.exclude_windows(&[])
4343
.build();

examples/02_window_capture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5555
println!("\nCapturing: {}\n", window.title().unwrap_or_default());
5656

5757
// 4. Create window filter
58-
let filter = SCContentFilter::build()
58+
let filter = SCContentFilter::builder()
5959
.window(window)
6060
.build();
6161

examples/03_audio_capture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4646
.ok_or("No displays found")?;
4747

4848
// 2. Create filter
49-
let filter = SCContentFilter::build()
49+
let filter = SCContentFilter::builder()
5050
.display(&display)
5151
.exclude_windows(&[])
5252
.build();

examples/04_pixel_access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6969
let display = content.displays().into_iter().next()
7070
.ok_or("No displays found")?;
7171

72-
let filter = SCContentFilter::build()
72+
let filter = SCContentFilter::builder()
7373
.display(&display)
7474
.exclude_windows(&[])
7575
.build();

examples/05_screenshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2929
println!("Display: {}x{}", display.width(), display.height());
3030

3131
// 2. Create filter
32-
let filter = SCContentFilter::build()
32+
let filter = SCContentFilter::builder()
3333
.display(&display)
3434
.exclude_windows(&[])
3535
.build();

examples/06_iosurface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5959
let display = content.displays().into_iter().next()
6060
.ok_or("No displays found")?;
6161

62-
let filter = SCContentFilter::build()
62+
let filter = SCContentFilter::builder()
6363
.display(&display)
6464
.exclude_windows(&[])
6565
.build();

examples/08_async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async fn async_stream_iteration() -> Result<(), Box<dyn std::error::Error>> {
141141
let displays = content.displays();
142142

143143
if let Some(display) = displays.first() {
144-
let filter = SCContentFilter::build()
144+
let filter = SCContentFilter::builder()
145145
.display(display)
146146
.exclude_windows(&[])
147147
.build();

examples/09_closure_handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2424
println!("Display: {}x{}\n", display.width(), display.height());
2525

2626
// Create filter and config
27-
let filter = SCContentFilter::build()
27+
let filter = SCContentFilter::builder()
2828
.display(&display)
2929
.exclude_windows(&[])
3030
.build();

src/stream/content_filter.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,21 @@ impl SCContentFilter {
9191
/// let content = SCShareableContent::get()?;
9292
/// let display = &content.displays()[0];
9393
///
94-
/// let filter = SCContentFilter::build()
94+
/// let filter = SCContentFilter::builder()
9595
/// .display(display)
9696
/// .exclude_windows(&[])
9797
/// .build();
9898
/// # Ok(())
9999
/// # }
100100
/// ```
101101
#[must_use]
102+
pub fn builder() -> SCContentFilterBuilder {
103+
SCContentFilterBuilder::new()
104+
}
105+
106+
/// Creates a new content filter builder (deprecated alias)
107+
#[deprecated(since = "1.0.0", note = "Use `builder()` instead")]
108+
#[must_use]
102109
pub fn build() -> SCContentFilterBuilder {
103110
SCContentFilterBuilder::new()
104111
}

0 commit comments

Comments
 (0)