KTVHCDataReader.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // KTVHCDataReader.h
  3. // KTVHTTPCache
  4. //
  5. // Created by Single on 2017/8/11.
  6. // Copyright © 2017年 Single. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class KTVHCDataReader;
  10. @class KTVHCDataRequest;
  11. @class KTVHCDataResponse;
  12. @protocol KTVHCDataReaderDelegate <NSObject>
  13. - (void)ktv_readerDidPrepare:(KTVHCDataReader *)reader;
  14. - (void)ktv_readerHasAvailableData:(KTVHCDataReader *)reader;
  15. - (void)ktv_reader:(KTVHCDataReader *)reader didFailWithError:(NSError *)error;
  16. @end
  17. @interface KTVHCDataReader : NSObject <NSLocking>
  18. + (instancetype)new NS_UNAVAILABLE;
  19. - (instancetype)init NS_UNAVAILABLE;
  20. @property (nonatomic, weak) id <KTVHCDataReaderDelegate> delegate;
  21. @property (nonatomic, strong) id object;
  22. @property (nonatomic, strong, readonly) KTVHCDataRequest *request;
  23. @property (nonatomic, strong, readonly) KTVHCDataResponse *response;
  24. @property (nonatomic, copy, readonly) NSError *error;
  25. @property (nonatomic, readonly, getter=isPrepared) BOOL prepared;
  26. @property (nonatomic, readonly, getter=isFinished) BOOL finished;
  27. @property (nonatomic, readonly, getter=isClosed) BOOL closed;
  28. @property (nonatomic, readonly) long long readedLength;
  29. @property (nonatomic, readonly) double progress;
  30. - (void)prepare;
  31. - (void)close;
  32. - (NSData *)readDataOfLength:(NSUInteger)length;
  33. @end