pub struct UnsupportedPixelFormat { /* private fields */ }Expand description
Payload for ConvertError::UnsupportedPixelFormat.
The frame’s pixel format isn’t in the closed CPU-format set this crate supports for safe per-plane access.
§A compact tag, and why it is not a PixelFormat
This payload used to carry the vocabulary’s PixelFormat beside the
raw id. mediaframe 0.11 widened that type’s text arm, which made
this the biggest arm of ConvertError at 144 bytes — a cost every
Result on the convert road pays on its success path. Boxing the
format fixed the size and introduced a worse thing: an infallible
allocation on the refusal path, so a container-selected
unsupported format could abort the process precisely while the
converter was trying to report it. An error that says “this is
unsupported” must not depend on the allocator agreeing.
So the payload is a tag: the raw AVPixelFormat integer, and
libavutil’s own name for it borrowed from the static descriptor
table. Twenty-four bytes, no allocation, no lifetime that can
dangle — the table outlives the process. The PixelFormat field is
gone rather than boxed, and its own documentation is why that costs
nothing: it said the vocabulary answer “is deliberately not made to
carry the integer: raw and name are where the identity
survives”. A caller that wants the vocabulary’s word for a raw id
can ask for it; a caller reading an error wants to know which format
was refused.
Implementations§
Source§impl UnsupportedPixelFormat
impl UnsupportedPixelFormat
Sourcepub const fn new(raw: i32, name: Option<&'static str>) -> Self
pub const fn new(raw: i32, name: Option<&'static str>) -> Self
Constructs an UnsupportedPixelFormat payload.
const again, and allocation-free: see the type’s own note.
Trait Implementations§
Source§impl Clone for UnsupportedPixelFormat
impl Clone for UnsupportedPixelFormat
Source§fn clone(&self) -> UnsupportedPixelFormat
fn clone(&self) -> UnsupportedPixelFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more