pub struct AssetImageSource { /* private fields */ }Expand description
The default image source: GPUI’s image loader
(Window::use_asset::<ImgResourceLoader>), which reads and decodes in
the background, renders an SVG in its own colours, and repaints the grid
when an image is ready. An animated GIF shows its first frame.
The id says where the image is:
| Id | Image | In a browser |
|---|---|---|
http://…, https://… | A URI, fetched by the application’s HTTP client (App::set_http_client); without one, missing | With gpui_web’s FetchHttpClient installed (and the server allowing the page’s origin); without it, missing |
| An absolute path | A file | Missing: no file system |
| Anything else | An asset of the application’s AssetSource | Works |
A missing image is never an error of the frame: the cell is empty and its text stays in the tooltip and for a screen reader.
Every image loaded is kept, as GPUI keeps its assets: memory grows with
the number of different images shown. Self::with_capacity keeps the
most recently used ones only. A clone shares the cache, so an
application can keep one to read Self::asset_requests.
Implementations§
Source§impl AssetImageSource
impl AssetImageSource
Sourcepub fn with_capacity(self, capacity: usize) -> Self
pub fn with_capacity(self, capacity: usize) -> Self
Keeps at most capacity images (at least one), dropping the least
recently used one, and GPUI’s copy of it, when another one comes.
The images of one frame are never dropped for one another: while
more different images than capacity are on screen, it keeps them
all.
Sourcepub fn asset_requests(&self) -> u64
pub fn asset_requests(&self) -> u64
How many times this source asked GPUI’s asset cache for an image: an image asks once a frame while it loads, and never once it is ready or missing. For benchmarks and tests.
Trait Implementations§
Source§impl CellImageSource for AssetImageSource
impl CellImageSource for AssetImageSource
Source§impl Clone for AssetImageSource
impl Clone for AssetImageSource
Source§fn clone(&self) -> AssetImageSource
fn clone(&self) -> AssetImageSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for AssetImageSource
impl Default for AssetImageSource
Source§fn default() -> AssetImageSource
fn default() -> AssetImageSource
Source§impl From<AssetImageSource> for CellImages
impl From<AssetImageSource> for CellImages
Source§fn from(source: AssetImageSource) -> Self
fn from(source: AssetImageSource) -> Self
Auto Trait Implementations§
impl Freeze for AssetImageSource
impl !RefUnwindSafe for AssetImageSource
impl !Send for AssetImageSource
impl !Sync for AssetImageSource
impl Unpin for AssetImageSource
impl UnsafeUnpin for AssetImageSource
impl !UnwindSafe for AssetImageSource
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> 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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().