pub trait ImagesExtension:
Send
+ Sync
+ Any {
// Provided methods
fn image(
&mut self,
limits: &ImageLimits,
source: &mut ImageSource,
options: &mut ImageOptions,
) { ... }
fn image_data(
&mut self,
max_decoded_len: ByteLength,
key: &ImageHash,
data: &IpcBytes,
format: &ImageDataFormat,
options: &ImageOptions,
) -> Option<ImageVar> { ... }
fn remove(&mut self, key: &mut ImageHash, purge: &mut bool) -> bool { ... }
fn clear(&mut self, purge: bool) { ... }
fn available_formats(&self, formats: &mut Vec<ImageFormat>) { ... }
}Expand description
A custom extension for the IMAGES service.
Extensions can intercept and modify requests.
Provided Methods§
Sourcefn image(
&mut self,
limits: &ImageLimits,
source: &mut ImageSource,
options: &mut ImageOptions,
)
fn image( &mut self, limits: &ImageLimits, source: &mut ImageSource, options: &mut ImageOptions, )
Modify a IMAGES.image request.
Note that all other request methods are shorthand helpers so this will be called for every request.
Note that the IMAGES service can be used in extensions and ImageSource::Image is returned directly by the service.
This can be used to fully replace a request here.
Sourcefn image_data(
&mut self,
max_decoded_len: ByteLength,
key: &ImageHash,
data: &IpcBytes,
format: &ImageDataFormat,
options: &ImageOptions,
) -> Option<ImageVar>
fn image_data( &mut self, max_decoded_len: ByteLength, key: &ImageHash, data: &IpcBytes, format: &ImageDataFormat, options: &ImageOptions, ) -> Option<ImageVar>
Image data loaded.
This is called for ImageSource::Read, ImageSource::Download and ImageSource::Data after the data is loaded and before
decoding starts.
Return a replacement variable to skip decoding or redirect to a different image. Note that by the time this is called the service
has already returned a variable in loading state, that variable will be cached according to mode. The replacement variable
is bound to the return variable and lives as long as it does.
Note that the IMAGES service can be used in extensions.
Sourcefn remove(&mut self, key: &mut ImageHash, purge: &mut bool) -> bool
fn remove(&mut self, key: &mut ImageHash, purge: &mut bool) -> bool
Modify a IMAGES.clean or IMAGES.purge request.
Return false to cancel the removal.
Sourcefn clear(&mut self, purge: bool)
fn clear(&mut self, purge: bool)
Called on IMAGES.clean_all and IMAGES.purge_all.
These operations cannot be intercepted, the service cache will be cleaned after this call.
Sourcefn available_formats(&self, formats: &mut Vec<ImageFormat>)
fn available_formats(&self, formats: &mut Vec<ImageFormat>)
Add or remove formats this extension affects.
The formats value starts with all formats implemented by the current view-process and will be returned
by IMAGES.available_formats after all proxies edit it.