Skip to main content

GifStreamPlayer

Struct GifStreamPlayer 

Source
pub struct GifStreamPlayer { /* private fields */ }
Expand description

Stateful streaming GIF player with reusable composite canvas, bounded pre-decode cache, disposal-aware dirty tracking, and off-screen pause/resume.

Implementations§

Source§

impl GifStreamPlayer

Reusable-canvas compositing, bounded pre-decode caching, disposal dirty reporting, and visibility pause/resume for GifStreamPlayer.

Source

pub fn from_bytes_with_config( bytes: &[u8], config: GifDecodeConfig, ) -> Result<Self, String>

Creates a streaming GIF player directly from raw .gif bytes and GifDecodeConfig.

§Arguments
  • &[u8] - Raw .gif file bytes.
  • GifDecodeConfig - Memory budget and frame-delay compatibility policy.
§Returns
  • Result<Self, String> - Initialized streaming GIF player or parse error.
Source

pub fn from_decoder(decoder: GifDecoder) -> Self

Creates a streaming GIF player from an already-parsed GifDecoder.

§Arguments
  • GifDecoder - Parsed GIF stream decoder.
§Returns
  • Self - Initialized streaming GIF player with reusable canvas.
Source

pub fn set_visible(&mut self, visible: bool)

Updates viewport visibility, suspending pre-decoding and timing while off-screen and resuming cleanly per visibility_policy.

§Arguments
  • &Self - Mutable streaming GIF player.
  • bool - true when the GIF is visible on screen, false when off-screen or frozen.
Source

pub fn predecode_upcoming(&mut self, window: usize) -> Result<usize, String>

Pre-decodes up to window upcoming frames into the bounded cache when visible (no-op when off-screen).

§Arguments
  • &Self - Mutable streaming GIF player.
  • usize - Maximum number of upcoming frames to pre-decode.
§Returns
  • Result<usize, String> - Number of frames present in the cache after pre-decoding.
Source

pub fn step_ms(&mut self, dt_ms: u32) -> Result<Option<GifDecodedFrame>, String>

Advances playback by dt_ms milliseconds when visible and playing, returning Some(GifDecodedFrame) whenever the active frame updates.

§Arguments
  • &Self - Mutable streaming GIF player.
  • u32 - Elapsed wall time in milliseconds.
§Returns
  • Result<Option<GifDecodedFrame>, String> - Newly active composited frame and dirty region, or None when unchanged/paused/off-screen.
Source

pub fn decode_frame( &mut self, target_index: usize, ) -> Result<GifDecodedFrame, String>

Returns the composited GifDecodedFrame for target_index, hitting the bounded cache when available or compositing sequentially on the reusable canvas.

§Arguments
  • &Self - Mutable streaming GIF player.
  • usize - Zero-based frame index.
§Returns
  • Result<GifDecodedFrame, String> - Composited frame with disposal-aware dirty rectangle or decode error.
Source§

impl GifStreamPlayer

Source

pub fn get_decoder(&self) -> &GifDecoder

Source

pub fn get_mut_decoder(&mut self) -> &mut GifDecoder

Source

pub fn set_decoder(&mut self, val: GifDecoder) -> &mut Self

Source

pub fn get_canvas(&self) -> &Vec<u8> ⓘ

Source

pub fn get_mut_canvas(&mut self) -> &mut Vec<u8> ⓘ

Source

pub fn set_canvas(&mut self, val: Vec<u8>) -> &mut Self

Source

pub fn get_cache(&self) -> &Vec<GifDecodedFrame>

Source

pub fn get_mut_cache(&mut self) -> &mut Vec<GifDecodedFrame>

Source

pub fn set_cache(&mut self, val: Vec<GifDecodedFrame>) -> &mut Self

Source

pub fn get_cache_bytes(&self) -> usize

Source

pub fn get_mut_cache_bytes(&mut self) -> &mut usize

Source

pub fn set_cache_bytes(&mut self, val: usize) -> &mut Self

Source

pub fn get_mut_last_composited_index(&mut self) -> &mut Option<usize>

Source

pub fn set_last_composited_index(&mut self, val: Option<usize>) -> &mut Self

Source

pub fn get_mut_pending_disposal_rect(&mut self) -> &mut Option<GifDirtyRect>

Source

pub fn set_pending_disposal_rect( &mut self, val: Option<GifDirtyRect>, ) -> &mut Self

Source

pub fn get_pending_disposal(&self) -> GifDisposalMethod

Source

pub fn get_mut_pending_disposal(&mut self) -> &mut GifDisposalMethod

Source

pub fn set_pending_disposal(&mut self, val: GifDisposalMethod) -> &mut Self

Source

pub fn get_current_frame(&self) -> usize

Source

pub fn get_mut_current_frame(&mut self) -> &mut usize

Source

pub fn set_current_frame(&mut self, val: usize) -> &mut Self

Source

pub fn get_elapsed_ms(&self) -> u32

Source

pub fn get_mut_elapsed_ms(&mut self) -> &mut u32

Source

pub fn set_elapsed_ms(&mut self, val: u32) -> &mut Self

Source

pub fn get_completed_loops(&self) -> u32

Source

pub fn get_mut_completed_loops(&mut self) -> &mut u32

Source

pub fn set_completed_loops(&mut self, val: u32) -> &mut Self

Source

pub fn get_visible(&self) -> bool

Source

pub fn get_mut_visible(&mut self) -> &mut bool

Source

pub fn get_visibility_policy(&self) -> GifVisibilityPolicy

Source

pub fn get_mut_visibility_policy(&mut self) -> &mut GifVisibilityPolicy

Source

pub fn set_visibility_policy(&mut self, val: GifVisibilityPolicy) -> &mut Self

Source

pub fn get_status(&self) -> GifPlaybackStatus

Source

pub fn get_mut_status(&mut self) -> &mut GifPlaybackStatus

Source

pub fn set_status(&mut self, val: GifPlaybackStatus) -> &mut Self

Source

pub fn get_last_dirty_rect(&self) -> GifDirtyRect

Source

pub fn get_mut_last_dirty_rect(&mut self) -> &mut GifDirtyRect

Source

pub fn set_last_dirty_rect(&mut self, val: GifDirtyRect) -> &mut Self

Source

pub fn get_cache_hits(&self) -> u64

Source

pub fn get_mut_cache_hits(&mut self) -> &mut u64

Source

pub fn set_cache_hits(&mut self, val: u64) -> &mut Self

Source

pub fn get_decode_count(&self) -> u64

Source

pub fn get_mut_decode_count(&mut self) -> &mut u64

Source

pub fn set_decode_count(&mut self, val: u64) -> &mut Self

Trait Implementations§

Source§

impl Clone for GifStreamPlayer

Source§

fn clone(&self) -> Self

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 Debug for GifStreamPlayer

Source§

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

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

impl Default for GifStreamPlayer

Source§

fn default() -> Self

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.