BU_SDWebImageCacheSerializer.h 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import <Foundation/Foundation.h>
  9. #import "BU_SDWebImageCompat.h"
  10. typedef NSData * _Nullable(^BU_SDWebImageCacheSerializerBlock)(UIImage * _Nonnull image, NSData * _Nullable data, NSURL * _Nullable imageURL);
  11. /**
  12. This is the protocol for cache serializer.
  13. We can use a block to specify the cache serializer. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options.
  14. */
  15. @protocol BU_SDWebImageCacheSerializer <NSObject>
  16. - (nullable NSData *)cacheDataWithImage:(nonnull UIImage *)image originalData:(nullable NSData *)data imageURL:(nullable NSURL *)imageURL;
  17. @end
  18. /**
  19. A cache serializer class with block.
  20. */
  21. @interface BU_SDWebImageCacheSerializer : NSObject <BU_SDWebImageCacheSerializer>
  22. - (nonnull instancetype)initWithBlock:(nonnull BU_SDWebImageCacheSerializerBlock)block;
  23. //+ (nonnull instancetype)cacheSerializerWithBlock:(nonnull BU_SDWebImageCacheSerializerBlock)block;
  24. @end