CacheSerializer
public protocol CacheSerializer
An CacheSerializer
is used to convert some data to an image object after
retrieving it from disk storage, and vice versa, to convert an image to data object
for storing to the disk storage.
-
Gets the serialized data from a provided image and optional original data for caching to disk.
Declaration
Swift
func data(with image: Image, original: Data?) -> Data?
Parameters
image
The image needed to be serialized.
original
The original data which is just downloaded. If the image is retrieved from cache instead of downloaded, it will be
nil
.Return Value
The data object for storing to disk, or
nil
when no valid data could be serialized. -
image(with:options:)
Default implementationGets an image from provided serialized data.
Default Implementation
Undocumented
Declaration
Swift
func image(with data: Data, options: KingfisherParsedOptionsInfo) -> Image?
Parameters
data
The data from which an image should be deserialized.
options
The parsed options for deserialization.
Return Value
An image deserialized or
nil
when no valid image could be deserialized. -
Gets an image deserialized from provided data.
Note
This method is deprecated. Please implement the version withKingfisherParsedOptionsInfo
as parameter instead.Declaration
Swift
@available(*, deprecated, message: "Deprecated. Implement the method with same name but with `KingfisherParsedOptionsInfo` instead.") func image(with data: Data, options: KingfisherOptionsInfo?) -> Image?
Parameters
data
The data from which an image should be deserialized.
options
Options for deserialization.
Return Value
An image deserialized or
nil
when no valid image could be deserialized.