IOSurface

Struct IOSurface 

Source
pub struct IOSurface(/* private fields */);
Expand description

Wrapper around IOSurface

IOSurface is a framebuffer object suitable for sharing across process boundaries. ScreenCaptureKit uses IOSurface-backed CVPixelBuffers for efficient frame delivery.

Implementations§

Source§

impl IOSurface

Source

pub fn width(&self) -> usize

Get the width of the IOSurface in pixels

Source

pub fn height(&self) -> usize

Get the height of the IOSurface in pixels

Source

pub fn bytes_per_row(&self) -> usize

Get the number of bytes per row

Source

pub fn pixel_format(&self) -> u32

Get the pixel format (OSType/FourCC)

Source

pub unsafe fn base_address(&self) -> *mut u8

Get the base address of the IOSurface buffer

Important: You must lock the IOSurface before accessing memory!

§Safety

The returned pointer is only valid while the IOSurface is locked. Accessing unlocked memory or after unlock is undefined behavior.

Source

pub fn lock( &self, options: IOSurfaceLockOptions, ) -> Result<IOSurfaceLockGuard<'_>, i32>

Lock the IOSurface and get a guard for safe access

The surface will be automatically unlocked when the guard is dropped.

§Errors

Returns an IOSurface error code if the lock operation fails.

§Example
let guard = surface.lock(IOSurfaceLockOptions::ReadOnly)?;
let data = guard.as_slice();
// Use data...
// Surface is automatically unlocked when guard goes out of scope
Source

pub fn is_in_use(&self) -> bool

Check if the IOSurface is currently in use

Trait Implementations§

Source§

impl Debug for IOSurface

Source§

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

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

impl Drop for IOSurface

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Hash for IOSurface

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for IOSurface

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for IOSurface

Source§

impl Send for IOSurface

Source§

impl Sync for IOSurface

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.