Skip to main content

PixelFormat

Enum PixelFormat 

Source
#[non_exhaustive]
pub enum PixelFormat { BGRA, l10r, YCbCr_420v, YCbCr_420f, xf44, RGhA, Unknown(FourCharCode), }
Expand description

Pixel format for captured video frames

Specifies the layout and encoding of pixel data in captured frames.

This enum is #[non_exhaustive]. Apple may add new pixel formats in future macOS releases; downstream code that exhaustively matches on PixelFormat must include a wildcard arm. Pixel formats this crate does not yet recognise are surfaced via the PixelFormat::Unknown variant rather than being silently coerced to PixelFormat::BGRA (which would mislead callers that branch on the format).

§Equality and hashing

PixelFormat compares and hashes by its underlying FourCharCode rather than by enum variant. This means PixelFormat::BGRA == PixelFormat::Unknown(FourCharCode::from_bytes(*b"BGRA")) — both round-trip to the same wire-level format — and they hash the same. Without this normalisation, the user-facing Unknown(known_code) footgun (constructing the variant with a code that already maps to a named variant) would silently produce two PixelFormat values that represent the same underlying format but compared unequal and indexed HashMaps twice.

§Examples

use screencapturekit::stream::configuration::PixelFormat;
use screencapturekit::FourCharCode;

let format = PixelFormat::BGRA;
println!("Format: {}", format); // Prints "BGRA"

// Equality normalises through FourCharCode:
let synonym = PixelFormat::Unknown(FourCharCode::from_bytes(*b"BGRA"));
assert_eq!(PixelFormat::BGRA, synonym);

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

BGRA

Packed little-endian 32-bit BGRA — the default pixel format for streams created via crate::stream::configuration::SCStreamConfiguration::new.

The crate pins this format at construction time so that SCStreamConfiguration::new() delivers a stable BGRA wire format across macOS releases. Without the explicit pin Apple’s runtime chooses its own default, which on macOS 26 / Apple Silicon is 420v (bi-planar YCbCr) — silently breaking consumers that assume packed BGRA samples. See issue #145.

§

l10r

Packed little endian ARGB2101010 (10-bit color)

§

YCbCr_420v

Two-plane “video” range YCbCr 4:2:0

§

YCbCr_420f

Two-plane “full” range YCbCr 4:2:0

§

xf44

Two-plane “full” range YCbCr10 4:4:4 (10-bit)

§

RGhA

64-bit RGBA IEEE half-precision float, 16-bit little-endian (HDR)

§

Unknown(FourCharCode)

A pixel format reported by ScreenCaptureKit that this crate does not model as a named variant. The wrapped FourCharCode preserves the raw four-character code so callers can branch on it explicitly or log it for diagnostics.

Trait Implementations§

Source§

impl Clone for PixelFormat

Source§

fn clone(&self) -> PixelFormat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for PixelFormat

Source§

impl Debug for PixelFormat

Source§

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

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

impl Default for PixelFormat

Source§

fn default() -> PixelFormat

Returns the “default value” for a type. Read more
Source§

impl Display for PixelFormat

Source§

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

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

impl Eq for PixelFormat

Source§

impl From<FourCharCode> for PixelFormat

Source§

fn from(val: FourCharCode) -> Self

Converts to this type from the input type.
Source§

impl From<PixelFormat> for FourCharCode

Source§

fn from(val: PixelFormat) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for PixelFormat

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for PixelFormat

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 PixelFormat

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.