pub struct Lqip(/* private fields */);Expand description
A chromahash LQIP payload — 32 bytes at [chromahash::DEFAULT_TIER].
Implementations§
Source§impl Lqip
impl Lqip
Sourcepub fn to_sidecar(&self) -> SidecarLqip
pub fn to_sidecar(&self) -> SidecarLqip
Build the encrypted-sidecar record: the chromahash payload, the LQIP_FORMAT_V1 tag,
and the dominant_color fill a reader paints when it cannot decode the payload.
Infallible — average_color is a DC read that cannot fail, and the payload is this
type’s invariant.
Source§impl Lqip
impl Lqip
Sourcepub fn encode(
width: u32,
height: u32,
rgba: &[u8],
gamut: Gamut,
) -> Result<Self, LqipError>
pub fn encode( width: u32, height: u32, rgba: &[u8], gamut: Gamut, ) -> Result<Self, LqipError>
Encode a full-resolution RGBA8 frame at the committed default tier.
rgba must be exactly width * height * 4 bytes of packed RGBA8, interpreted in
gamut. The frame is not pre-resized: chromahash consumes the whole thing and
band-limits at decode_capped time.
Bit-exact for a given (width, height, rgba, gamut) on every platform chromahash
supports, which is what lets the CLI, the FFI and capsule-wasm agree byte-for-byte.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, LqipError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, LqipError>
Parse sidecar bytes back into a payload, validating version, tier, reserved bits and
length. An Ok value is guaranteed to decode.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
The raw payload — what the sidecar’s lqip.chromahash field carries.
Sourcepub fn dominant_color(&self) -> [u8; 3]
pub fn dominant_color(&self) -> [u8; 3]
The average colour as opaque RGB — the dominant_color fallback fill, read straight
from the DC coefficients without a full decode.
Sourcepub fn average_rgba(&self) -> [u8; 4]
pub fn average_rgba(&self) -> [u8; 4]
The average colour as RGBA, alpha included.
Sourcepub fn decode_capped(&self, max_width: u32, max_height: u32) -> RgbaImage
pub fn decode_capped(&self, max_width: u32, max_height: u32) -> RgbaImage
Decode to a placeholder no larger than max_width x max_height — a band-limited,
alias-free render of exactly the box being painted, rather than a full-size decode the
caller then scales down.
A zero bound is raised to 1: chromahash would otherwise return an empty buffer, and every caller of this is about to paint something.
Trait Implementations§
impl Eq for Lqip
impl StructuralPartialEq for Lqip
Auto Trait Implementations§
impl Freeze for Lqip
impl RefUnwindSafe for Lqip
impl Send for Lqip
impl Sync for Lqip
impl Unpin for Lqip
impl UnsafeUnpin for Lqip
impl UnwindSafe for Lqip
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more