pub trait ResizeEncodeRender {
// Required methods
fn resize_encode(&mut self, resize: &Resize, area: Rect);
fn render(&mut self, area: Rect, buf: &mut Buffer);
fn needs_resize(&self, resize: &Resize, area: Rect) -> Option<Rect>;
// Provided method
fn resize_encode_render(
&mut self,
resize: &Resize,
area: Rect,
buf: &mut Buffer,
) { ... }
}Required Methods§
Sourcefn resize_encode(&mut self, resize: &Resize, area: Rect)
fn resize_encode(&mut self, resize: &Resize, area: Rect)
Resize the image and encode it for rendering. The result should be stored statefully so that next call for the given area does not need to redo the work.
This can be done in a background thread, and the result is stored in this protocol::StatefulProtocol.
Sourcefn render(&mut self, area: Rect, buf: &mut Buffer)
fn render(&mut self, area: Rect, buf: &mut Buffer)
Render the currently resized and encoded data to the buffer.
Sourcefn needs_resize(&self, resize: &Resize, area: Rect) -> Option<Rect>
fn needs_resize(&self, resize: &Resize, area: Rect) -> Option<Rect>
Check if the current image state would need resizing (grow or shrink) for the given area.
This can be called by the UI thread to check if this protocol::StatefulProtocol should be sent off to some background thread/task to do the resizing and encoding, instead of rendering. The thread should then return the protocol::StatefulProtocol so that it can be rendered.
Provided Methods§
Sourcefn resize_encode_render(
&mut self,
resize: &Resize,
area: Rect,
buf: &mut Buffer,
)
fn resize_encode_render( &mut self, resize: &Resize, area: Rect, buf: &mut Buffer, )
Resize and encode if necessary, and render immediately.