pub struct FormatOption {
pub descriptor: PixelDescriptor,
pub consumer_cost: ConversionCost,
}Expand description
A supported format with optional consumer-provided cost override.
Use this with best_match_with when the consumer can handle some
formats more efficiently than the default conversion path.
§Example
A JPEG encoder with a fast internal f32→u8 path:
ⓘ
use zenpixels::{FormatOption, ConversionCost};
use zenpixels::PixelDescriptor;
let options = &[
FormatOption::from(PixelDescriptor::RGB8_SRGB), // native, zero cost
FormatOption::with_cost(
PixelDescriptor::RGBF32_LINEAR,
ConversionCost::new(5, 0), // fast fused path, no extra loss
),
];Fields§
§descriptor: PixelDescriptorThe pixel format the consumer can accept.
consumer_cost: ConversionCostAdditional cost the consumer incurs to handle this format after we deliver it. Zero for native formats.
Implementations§
Source§impl FormatOption
impl FormatOption
Sourcepub const fn with_cost(
descriptor: PixelDescriptor,
consumer_cost: ConversionCost,
) -> Self
pub const fn with_cost( descriptor: PixelDescriptor, consumer_cost: ConversionCost, ) -> Self
Create an option with explicit consumer cost.
Trait Implementations§
Source§impl Clone for FormatOption
impl Clone for FormatOption
Source§fn clone(&self) -> FormatOption
fn clone(&self) -> FormatOption
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FormatOption
impl Debug for FormatOption
Source§impl From<PixelDescriptor> for FormatOption
impl From<PixelDescriptor> for FormatOption
Source§fn from(descriptor: PixelDescriptor) -> Self
fn from(descriptor: PixelDescriptor) -> Self
Converts to this type from the input type.
impl Copy for FormatOption
Auto Trait Implementations§
impl Freeze for FormatOption
impl RefUnwindSafe for FormatOption
impl Send for FormatOption
impl Sync for FormatOption
impl Unpin for FormatOption
impl UnsafeUnpin for FormatOption
impl UnwindSafe for FormatOption
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more