pub struct WallpaperBundle { /* private fields */ }Expand description
A wallpaper that adapts to landscape vs portrait surfaces.
Holds a single full-resolution landscape image and lazily produces left-cropped portrait variants on demand, caching the most recently requested crop dimensions.
Implementations§
Source§impl WallpaperBundle
impl WallpaperBundle
Sourcepub fn from_decoded(landscape: ImageData) -> Self
pub fn from_decoded(landscape: ImageData) -> Self
Wrap an already-decoded landscape image.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, ImageError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ImageError>
Decode bytes (PNG/JPEG) as the landscape image.
Sourcepub fn from_path_or_bytes(path: Option<&Path>, bundled_fallback: &[u8]) -> Self
pub fn from_path_or_bytes(path: Option<&Path>, bundled_fallback: &[u8]) -> Self
Try to load the landscape image from path; on failure fall back to
decoding bundled_fallback (typically a include_bytes! asset shipped
inside the consumer binary). Errors loading the path are reported on
stderr.
Sourcepub fn from_path_or_solid(path: Option<&Path>, r: u8, g: u8, b: u8) -> Self
pub fn from_path_or_solid(path: Option<&Path>, r: u8, g: u8, b: u8) -> Self
Try to load from path; on failure produce a 1×1 solid-colour bundle
using (r, g, b) instead of requiring embedded PNG bytes. Reports path
load errors on stderr.
Sourcepub fn landscape(&self) -> ImageData
pub fn landscape(&self) -> ImageData
The original landscape image. Cheap clone — only bumps the inner Arc.
Sourcepub fn for_size(&self, sw: u32, sh: u32) -> ImageData
pub fn for_size(&self, sw: u32, sh: u32) -> ImageData
Return the wallpaper variant appropriate for a surface of (sw, sh).
- Landscape surface (
sw >= sh): returns the full landscape image. - Portrait surface (
sw < sh): returns a left-cropped variant whose aspect ratio matches(sw, sh). The crop is computed once per unique(sw, sh)pair and reused on subsequent calls.
(0, 0) is treated as landscape (returns the original image) so that
callers can use this before the surface has been sized.
Auto Trait Implementations§
impl !Freeze for WallpaperBundle
impl RefUnwindSafe for WallpaperBundle
impl Send for WallpaperBundle
impl Sync for WallpaperBundle
impl Unpin for WallpaperBundle
impl UnwindSafe for WallpaperBundle
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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