Skip to content

Commit d9ded58

Browse files
committed
docs(ffi_string): fix ignored doctest with working example
1 parent 4225d33 commit d9ded58

29 files changed

Lines changed: 133 additions & 400 deletions

examples/05_screenshot.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5353

5454
let file = std::fs::File::create(filename)?;
5555
let buf_writer = std::io::BufWriter::new(file);
56-
#[allow(clippy::cast_possible_truncation)]
5756
let mut encoder = png::Encoder::new(buf_writer, width as u32, height as u32);
5857
encoder.set_color(png::ColorType::Rgba);
5958
encoder.set_depth(png::BitDepth::Eight);

src/output/iosurface.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ impl IOSurface {
194194
}
195195
}
196196

197-
/// Get the raw pointer
198-
#[allow(dead_code)]
199-
pub(crate) const fn as_ptr(&self) -> *const c_void {
200-
self.0
201-
}
202-
203197
/// Get the width of the IOSurface in pixels
204198
pub fn width(&self) -> usize {
205199
// FFI returns isize but dimensions are always positive

src/output/sc_stream_frame_info.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ mod internal {
173173
/// # Panics
174174
///
175175
/// Panics if .
176-
///
177-
#[allow(clippy::needless_pass_by_value)]
178176
fn dict_to_cg_rect(cf_rect_raw: CFDictionary) -> CGRect {
179177
let cf_rect = unsafe {
180178
CFDictionary::<CFString, CFNumber>::wrap_under_get_rule(

src/screenshot_manager.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +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-
/// # #[allow(deprecated)]
68-
/// let filter = SCContentFilter::new().with_display_excluding_windows(display, &[]);
69-
/// let config = SCStreamConfiguration::new();
67+
/// let filter = SCContentFilter::build().display(display).exclude_windows(&[]).build();
68+
/// let config = SCStreamConfiguration::build();
7069
///
7170
/// let image = SCScreenshotManager::capture_image(&filter, &config)?;
7271
/// println!("Screenshot size: {}x{}", image.width(), image.height());
@@ -93,9 +92,8 @@ impl CGImage {
9392
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
9493
/// # let content = SCShareableContent::get()?;
9594
/// # let display = &content.displays()[0];
96-
/// # #[allow(deprecated)]
97-
/// # let filter = SCContentFilter::new().with_display_excluding_windows(display, &[]);
98-
/// # let config = SCStreamConfiguration::new();
95+
/// # let filter = SCContentFilter::build().display(display).exclude_windows(&[]).build();
96+
/// # let config = SCStreamConfiguration::build();
9997
/// let image = SCScreenshotManager::capture_image(&filter, &config)?;
10098
/// let width = image.width();
10199
/// println!("Width: {}", width);
@@ -182,9 +180,8 @@ unsafe impl Sync for CGImage {}
182180
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
183181
/// let content = SCShareableContent::get()?;
184182
/// let display = &content.displays()[0];
185-
/// # #[allow(deprecated)]
186-
/// let filter = SCContentFilter::new().with_display_excluding_windows(display, &[]);
187-
/// let config = SCStreamConfiguration::new()
183+
/// let filter = SCContentFilter::build().display(display).exclude_windows(&[]).build();
184+
/// let config = SCStreamConfiguration::build()
188185
/// .set_width(1920)?
189186
/// .set_height(1080)?;
190187
///

src/stream/configuration/mod.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub mod pixel_format;
1010
pub mod stream_properties;
1111
pub mod types;
1212

13-
#[allow(clippy::module_name_repetitions)]
1413
pub use advanced::SCPresenterOverlayAlertSetting;
1514
pub use internal::SCStreamConfiguration;
1615
pub use pixel_format::PixelFormat;
@@ -34,23 +33,6 @@ impl SCStreamConfiguration {
3433
pub fn build() -> Self {
3534
Self::internal_init()
3635
}
37-
38-
/// Creates a new stream configuration (deprecated - use build())
39-
///
40-
/// # Deprecated
41-
/// Use `SCStreamConfiguration::build()` instead:
42-
/// ```rust
43-
/// use screencapturekit::stream::configuration::SCStreamConfiguration;
44-
///
45-
/// let config = SCStreamConfiguration::build()
46-
/// .set_width(1920)
47-
/// .unwrap();
48-
/// ```
49-
#[deprecated(since = "1.0.0", note = "Use SCStreamConfiguration::build() instead")]
50-
#[must_use]
51-
pub fn new() -> Self {
52-
Self::internal_init()
53-
}
5436
}
5537

5638
impl Default for SCStreamConfiguration {

src/stream/content_filter.rs

Lines changed: 0 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -103,198 +103,6 @@ impl SCContentFilter {
103103
SCContentFilterBuilder::new()
104104
}
105105

106-
/// Creates a new content filter (deprecated - use builder pattern)
107-
///
108-
/// # Deprecated
109-
/// Use the builder pattern instead:
110-
/// ```no_run
111-
/// # use screencapturekit::prelude::*;
112-
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
113-
/// # let content = SCShareableContent::get()?;
114-
/// # let display = &content.displays()[0];
115-
/// let filter = SCContentFilter::build()
116-
/// .display(display)
117-
/// .exclude_windows(&[])
118-
/// .build();
119-
/// # Ok(())
120-
/// # }
121-
/// ```
122-
#[deprecated(since = "1.0.0", note = "Use SCContentFilter::build() instead")]
123-
#[must_use]
124-
pub fn new() -> Self {
125-
Self(std::ptr::null())
126-
}
127-
128-
/// Creates a content filter with a desktop independent window (deprecated)
129-
///
130-
/// # Deprecated
131-
/// Use the builder pattern instead:
132-
/// ```no_run
133-
/// # use screencapturekit::prelude::*;
134-
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
135-
/// # let content = SCShareableContent::get()?;
136-
/// # let window = &content.windows()[0];
137-
/// let filter = SCContentFilter::build()
138-
/// .window(window)
139-
/// .build();
140-
/// # Ok(())
141-
/// # }
142-
/// ```
143-
#[deprecated(since = "1.0.0", note = "Use SCContentFilter::build().window().build() instead")]
144-
#[must_use]
145-
pub fn with_desktop_independent_window(self, window: &SCWindow) -> Self {
146-
// Drop the old filter if any
147-
if !self.0.is_null() {
148-
unsafe { ffi::sc_content_filter_release(self.0); }
149-
}
150-
std::mem::forget(self); // Prevent double-free
151-
152-
unsafe {
153-
let filter = ffi::sc_content_filter_create_with_desktop_independent_window(window.as_ptr());
154-
Self(filter)
155-
}
156-
}
157-
158-
/// Creates a content filter with a display, excluding specific windows (deprecated)
159-
///
160-
/// # Deprecated
161-
/// Use the builder pattern instead:
162-
/// ```no_run
163-
/// # use screencapturekit::prelude::*;
164-
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
165-
/// # let content = SCShareableContent::get()?;
166-
/// # let display = &content.displays()[0];
167-
/// # let window = &content.windows()[0];
168-
/// // Capture entire display
169-
/// let filter = SCContentFilter::build()
170-
/// .display(display)
171-
/// .exclude_windows(&[])
172-
/// .build();
173-
///
174-
/// // Or exclude specific windows
175-
/// let filter = SCContentFilter::build()
176-
/// .display(display)
177-
/// .exclude_windows(&[window])
178-
/// .build();
179-
/// # Ok(())
180-
/// # }
181-
/// ```
182-
#[deprecated(since = "1.0.0", note = "Use SCContentFilter::build().display().exclude_windows().build() instead")]
183-
#[must_use]
184-
pub fn with_display_excluding_windows(
185-
self,
186-
display: &SCDisplay,
187-
excluding_windows: &[&SCWindow],
188-
) -> Self {
189-
// Drop the old filter if any
190-
if !self.0.is_null() {
191-
unsafe { ffi::sc_content_filter_release(self.0); }
192-
}
193-
std::mem::forget(self); // Prevent double-free
194-
unsafe {
195-
let window_ptrs: Vec<*const c_void> = excluding_windows
196-
.iter()
197-
.map(|w| w.as_ptr())
198-
.collect();
199-
200-
let filter = if window_ptrs.is_empty() {
201-
ffi::sc_content_filter_create_with_display_excluding_windows(
202-
display.as_ptr(),
203-
std::ptr::null(),
204-
0,
205-
)
206-
} else {
207-
// FFI expects isize for array length (Objective-C NSInteger)
208-
#[allow(clippy::cast_possible_wrap)]
209-
ffi::sc_content_filter_create_with_display_excluding_windows(
210-
display.as_ptr(),
211-
window_ptrs.as_ptr(),
212-
window_ptrs.len() as isize,
213-
)
214-
};
215-
216-
Self(filter)
217-
}
218-
}
219-
220-
/// Creates a content filter with a display, including specific windows (deprecated)
221-
#[deprecated(since = "1.0.0", note = "Use SCContentFilter::build().display().include_windows().build() instead")]
222-
#[must_use]
223-
pub fn with_display_including_windows(
224-
self,
225-
display: &SCDisplay,
226-
including_windows: &[&SCWindow],
227-
) -> Self {
228-
// Drop the old filter if any
229-
if !self.0.is_null() {
230-
unsafe { ffi::sc_content_filter_release(self.0); }
231-
}
232-
std::mem::forget(self); // Prevent double-free
233-
unsafe {
234-
let window_ptrs: Vec<*const c_void> = including_windows
235-
.iter()
236-
.map(|w| w.as_ptr())
237-
.collect();
238-
239-
let filter = if window_ptrs.is_empty() {
240-
ffi::sc_content_filter_create_with_display_including_windows(
241-
display.as_ptr(),
242-
std::ptr::null(),
243-
0,
244-
)
245-
} else {
246-
// FFI expects isize for array length (Objective-C NSInteger)
247-
#[allow(clippy::cast_possible_wrap)]
248-
ffi::sc_content_filter_create_with_display_including_windows(
249-
display.as_ptr(),
250-
window_ptrs.as_ptr(),
251-
window_ptrs.len() as isize,
252-
)
253-
};
254-
255-
Self(filter)
256-
}
257-
}
258-
259-
/// Creates a content filter with a display, including applications and excepting specific windows (deprecated)
260-
#[deprecated(since = "1.0.0", note = "Use SCContentFilter::build().display().include_applications().build() instead")]
261-
#[must_use]
262-
pub fn with_display_including_applications_excepting_windows(
263-
self,
264-
display: &SCDisplay,
265-
applications: &[&SCRunningApplication],
266-
excepting_windows: &[&SCWindow],
267-
) -> Self {
268-
// Drop the old filter if any
269-
if !self.0.is_null() {
270-
unsafe { ffi::sc_content_filter_release(self.0); }
271-
}
272-
std::mem::forget(self); // Prevent double-free
273-
unsafe {
274-
let app_ptrs: Vec<*const c_void> = applications
275-
.iter()
276-
.map(|a| a.as_ptr())
277-
.collect();
278-
279-
let window_ptrs: Vec<*const c_void> = excepting_windows
280-
.iter()
281-
.map(|w| w.as_ptr())
282-
.collect();
283-
284-
// FFI expects isize for array lengths (Objective-C NSInteger)
285-
#[allow(clippy::cast_possible_wrap)]
286-
let filter = ffi::sc_content_filter_create_with_display_including_applications_excepting_windows(
287-
display.as_ptr(),
288-
if app_ptrs.is_empty() { std::ptr::null() } else { app_ptrs.as_ptr() },
289-
app_ptrs.len() as isize,
290-
if window_ptrs.is_empty() { std::ptr::null() } else { window_ptrs.as_ptr() },
291-
window_ptrs.len() as isize,
292-
);
293-
294-
Self(filter)
295-
}
296-
}
297-
298106
/// Returns the raw pointer to the content filter
299107
pub(crate) fn as_ptr(&self) -> *const c_void {
300108
self.0

src/stream/delegate_trait.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use crate::error::SCError;
3131
/// }
3232
/// }
3333
/// ```
34-
#[allow(clippy::module_name_repetitions)]
3534
pub trait SCStreamDelegateTrait: Send {
3635
/// Called when video effects start
3736
fn output_video_effect_did_start_for_stream(&self) {}

src/stream/internal/cleanup.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ impl Cleanup {
3232
self.handlers.iter().take_while(|&&x| !x.is_null())
3333
}
3434

35-
#[allow(clippy::needless_pass_by_ref_mut)]
3635
pub fn drop_handlers(&mut self) {
3736
if self.rc.fetch_sub(1, Ordering::Release) != 1 {
3837
return;

src/stream/internal/ffi_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macro_rules! declare_trait_wrapper {
99
pub fn new(handler: impl $t + 'a) -> Self {
1010
Self(Box::into_raw(Box::new(Box::new(handler))))
1111
}
12-
#[allow(dead_code)]
12+
1313
pub fn drop_trait(&self) {
1414
unsafe {
1515
let _ = Box::from_raw(self.0);

src/stream/internal/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" {
3232
}
3333

3434
pub type SCStreamRef = *mut __SCStreamRef;
35-
#[allow(clippy::module_name_repetitions)]
35+
3636
pub struct SCStream(SCStreamRef);
3737

3838
impl_TCFType!(SCStream, SCStreamRef, SCStreamGetTypeID);

0 commit comments

Comments
 (0)