forked from onevcat/Kingfisher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CacheSerializer.html
499 lines (492 loc) · 23.6 KB
/
CacheSerializer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
<!DOCTYPE html>
<html lang="en">
<head>
<title>CacheSerializer Protocol Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset='utf-8'>
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Protocol/CacheSerializer" class="dashAnchor"></a>
<a title="CacheSerializer Protocol Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">Kingfisher Docs</a> (77% documented)</p>
<p class="header-right"><a href="https://github.com/onevcat/Kingfisher"><img src="../img/gh.png"/>View on GitHub</a></p>
<p class="header-right"><a href="dash-feed://http%3A%2F%2Fonevcat%2Egithub%2Eio%2FKingfisher%2Fdocsets%2FKingfisher%2Exml"><img src="../img/dash.png"/>Install in Dash</a></p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="../index.html">Kingfisher Reference</a>
<img id="carat" src="../img/carat.png" />
CacheSerializer Protocol Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="../Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Classes/AnimatedImageView.html">AnimatedImageView</a>
</li>
<li class="nav-group-task">
<a href="../Classes/AnimatedImageView/RepeatCount.html">– RepeatCount</a>
</li>
<li class="nav-group-task">
<a href="../Classes/ImageCache.html">ImageCache</a>
</li>
<li class="nav-group-task">
<a href="../Classes/ImageCache/CacheCheckResult.html">– CacheCheckResult</a>
</li>
<li class="nav-group-task">
<a href="../Classes/ImageDownloader.html">ImageDownloader</a>
</li>
<li class="nav-group-task">
<a href="../Classes/ImagePrefetcher.html">ImagePrefetcher</a>
</li>
<li class="nav-group-task">
<a href="../Classes/Kingfisher.html">Kingfisher</a>
</li>
<li class="nav-group-task">
<a href="../Classes/KingfisherManager.html">KingfisherManager</a>
</li>
<li class="nav-group-task">
<a href="../Classes/RetrieveImageTask.html">RetrieveImageTask</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Global Variables.html">Global Variables</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Global Variables.html#/s:10Kingfisher0A23DiskCacheCleanedHashKeySSvp">KingfisherDiskCacheCleanedHashKey</a>
</li>
<li class="nav-group-task">
<a href="../Global Variables.html#/s:10Kingfisher0A11ErrorDomainSSvp">KingfisherErrorDomain</a>
</li>
<li class="nav-group-task">
<a href="../Global Variables.html#/s:10Kingfisher0A18ErrorStatusCodeKeySSvp">KingfisherErrorStatusCodeKey</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Enums/CacheType.html">CacheType</a>
</li>
<li class="nav-group-task">
<a href="../Enums/ContentMode.html">ContentMode</a>
</li>
<li class="nav-group-task">
<a href="../Enums/ImageProcessItem.html">ImageProcessItem</a>
</li>
<li class="nav-group-task">
<a href="../Enums/ImageTransition.html">ImageTransition</a>
</li>
<li class="nav-group-task">
<a href="../Enums/ImageTransition.html">ImageTransition</a>
</li>
<li class="nav-group-task">
<a href="../Enums/IndicatorType.html">IndicatorType</a>
</li>
<li class="nav-group-task">
<a href="../Enums/KingfisherError.html">KingfisherError</a>
</li>
<li class="nav-group-task">
<a href="../Enums/KingfisherOptionsInfoItem.html">KingfisherOptionsInfoItem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Extensions/CGSize.html">CGSize</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/Collection.html">Collection</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/Data.html">Data</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/Notification.html">Notification</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/Notification/Name.html">– Name</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/String.html">String</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/URL.html">URL</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Functions.html">Functions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Functions.html#/s:10Kingfisher2ggoiAA14ImageProcessor_pAaC_p_AaC_ptF">>>(_:_:)</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Protocols/AnimatedImageViewDelegate.html">AnimatedImageViewDelegate</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/AuthenticationChallengeResponsable.html">AuthenticationChallengeResponsable</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/CIImageProcessor.html">CIImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/CacheSerializer.html">CacheSerializer</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/ImageDownloadRequestModifier.html">ImageDownloadRequestModifier</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/ImageDownloaderDelegate.html">ImageDownloaderDelegate</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/ImageModifier.html">ImageModifier</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/ImageProcessor.html">ImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/Indicator.html">Indicator</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/KingfisherCompatible.html">KingfisherCompatible</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/Placeholder.html">Placeholder</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/Resource.html">Resource</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Structs/AlignmentRectInsetsImageModifier.html">AlignmentRectInsetsImageModifier</a>
</li>
<li class="nav-group-task">
<a href="../Structs/AnyImageModifier.html">AnyImageModifier</a>
</li>
<li class="nav-group-task">
<a href="../Structs/AnyModifier.html">AnyModifier</a>
</li>
<li class="nav-group-task">
<a href="../Structs/BlackWhiteProcessor.html">BlackWhiteProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs/BlendImageProcessor.html">BlendImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs/BlurImageProcessor.html">BlurImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs.html#/s:10Kingfisher11CGSizeProxyV">CGSizeProxy</a>
</li>
<li class="nav-group-task">
<a href="../Structs/ColorControlsProcessor.html">ColorControlsProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs/CompositingImageProcessor.html">CompositingImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs/CroppingImageProcessor.html">CroppingImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs.html#/s:10Kingfisher9DataProxyV">DataProxy</a>
</li>
<li class="nav-group-task">
<a href="../Structs/DefaultCacheSerializer.html">DefaultCacheSerializer</a>
</li>
<li class="nav-group-task">
<a href="../Structs/DefaultImageModifier.html">DefaultImageModifier</a>
</li>
<li class="nav-group-task">
<a href="../Structs/DefaultImageProcessor.html">DefaultImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs/Filter.html">Filter</a>
</li>
<li class="nav-group-task">
<a href="../Structs/FlipsForRightToLeftLayoutDirectionImageModifier.html">FlipsForRightToLeftLayoutDirectionImageModifier</a>
</li>
<li class="nav-group-task">
<a href="../Structs/FormatIndicatedCacheSerializer.html">FormatIndicatedCacheSerializer</a>
</li>
<li class="nav-group-task">
<a href="../Structs/ImageResource.html">ImageResource</a>
</li>
<li class="nav-group-task">
<a href="../Structs/OverlayImageProcessor.html">OverlayImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs/RectCorner.html">RectCorner</a>
</li>
<li class="nav-group-task">
<a href="../Structs/RenderingModeImageModifier.html">RenderingModeImageModifier</a>
</li>
<li class="nav-group-task">
<a href="../Structs/ResizingImageProcessor.html">ResizingImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs/RetrieveImageDownloadTask.html">RetrieveImageDownloadTask</a>
</li>
<li class="nav-group-task">
<a href="../Structs/RoundCornerImageProcessor.html">RoundCornerImageProcessor</a>
</li>
<li class="nav-group-task">
<a href="../Structs.html#/s:10Kingfisher11StringProxyV">StringProxy</a>
</li>
<li class="nav-group-task">
<a href="../Structs/TintImageProcessor.html">TintImageProcessor</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Typealiases.html#/Button">Button</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher6Buttona">Button</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/Color">Color</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher5Colora">Color</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher17CompletionHandlera">CompletionHandler</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher21DownloadProgressBlocka">DownloadProgressBlock</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/Image">Image</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher5Imagea">Image</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher32ImageDownloaderCompletionHandlera">ImageDownloaderCompletionHandler</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher28ImageDownloaderProgressBlocka">ImageDownloaderProgressBlock</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/ImageView">ImageView</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher9ImageViewa">ImageView</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/IndicatorView">IndicatorView</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher13IndicatorViewa">IndicatorView</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher0A11OptionsInfoa">KingfisherOptionsInfo</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher27PrefetcherCompletionHandlera">PrefetcherCompletionHandler</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher23PrefetcherProgressBlocka">PrefetcherProgressBlock</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher21RetrieveImageDiskTaska">RetrieveImageDiskTask</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher11Transformera">Transformer</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/View">View</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:10Kingfisher4Viewa">View</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>CacheSerializer</h1>
<div class="declaration">
<div class="language">
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">CacheSerializer</span></code></pre>
</div>
</div>
<p>An <code>CacheSerializer</code> would be used to convert some data to an image object for
retrieving from disk cache and vice versa for storing to disk cache.</p>
</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:10Kingfisher15CacheSerializerP4data10Foundation4DataVSgSo7UIImageC4with_AH8originaltF"></a>
<a name="//apple_ref/swift/Method/data(with:original:)" class="dashAnchor"></a>
<a class="token" href="#/s:10Kingfisher15CacheSerializerP4data10Foundation4DataVSgSo7UIImageC4with_AH8originaltF">data(with:original:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get the serialized data from a provided image
and optional original data for caching to disk.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">data</span><span class="p">(</span><span class="n">with</span> <span class="nv">image</span><span class="p">:</span> <span class="kt"><a href="../Typealiases.html#/Image">Image</a></span><span class="p">,</span> <span class="nv">original</span><span class="p">:</span> <span class="kt">Data</span><span class="p">?)</span> <span class="o">-></span> <span class="kt">Data</span><span class="p">?</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>image</em>
</code>
</td>
<td>
<div>
<p>The image needed to be serialized.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>original</em>
</code>
</td>
<td>
<div>
<p>The original data which is just downloaded.
If the image is retrieved from cache instead of
downloaded, it will be <code>nil</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<h4>Return Value</h4>
<p>A data which will be stored to cache, or <code>nil</code> when no valid
data could be serialized.</p>
</div>
<div class="slightly-smaller">
<a href="https://github.com/onevcat/Kingfisher/tree/4.8.0/Sources/CacheSerializer.swift#L44">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10Kingfisher15CacheSerializerP5imageSo7UIImageCSg10Foundation4DataV4with_SayAA0A15OptionsInfoItemOGSg7optionstF"></a>
<a name="//apple_ref/swift/Method/image(with:options:)" class="dashAnchor"></a>
<a class="token" href="#/s:10Kingfisher15CacheSerializerP5imageSo7UIImageCSg10Foundation4DataV4with_SayAA0A15OptionsInfoItemOGSg7optionstF">image(with:options:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get an image deserialized from provided data.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">image</span><span class="p">(</span><span class="n">with</span> <span class="nv">data</span><span class="p">:</span> <span class="kt">Data</span><span class="p">,</span> <span class="nv">options</span><span class="p">:</span> <span class="kt"><a href="../Typealiases.html#/s:10Kingfisher0A11OptionsInfoa">KingfisherOptionsInfo</a></span><span class="p">?)</span> <span class="o">-></span> <span class="kt"><a href="../Typealiases.html#/Image">Image</a></span><span class="p">?</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>data</em>
</code>
</td>
<td>
<div>
<p>The data from which an image should be deserialized.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>options</em>
</code>
</td>
<td>
<div>
<p>Options for deserialization.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<h4>Return Value</h4>
<p>An image deserialized or <code>nil</code> when no valid image
could be deserialized.</p>
</div>
<div class="slightly-smaller">
<a href="https://github.com/onevcat/Kingfisher/tree/4.8.0/Sources/CacheSerializer.swift#L53">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>© 2018 <a class="link" href="https://onevcat.com" target="_blank" rel="external">Wei Wang</a>. All rights reserved. (Last updated: 2018-05-15)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.4</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>