KTVHCDataReader.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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)readerDidPrepared:(KTVHCDataReader *)reader;
  14. - (void)readerHasAvailableData:(KTVHCDataReader *)reader;
  15. - (void)reader:(KTVHCDataReader *)reader didFailed:(NSError *)error;
  16. @end
  17. @interface KTVHCDataReader : NSObject <NSLocking>
  18. + (instancetype)new NS_UNAVAILABLE;
  19. - (instancetype)init NS_UNAVAILABLE;
  20. + (instancetype)readerWithRequest:(KTVHCDataRequest *)request;
  21. @property (nonatomic, weak) id <KTVHCDataReaderDelegate> delegate;
  22. @property (nonatomic, strong) id object;
  23. @property (nonatomic, strong, readonly) KTVHCDataRequest * request;
  24. @property (nonatomic, strong, readonly) KTVHCDataResponse * response;
  25. @property (nonatomic, strong, readonly) NSError * error;
  26. @property (nonatomic, assign, readonly) BOOL didClosed;
  27. @property (nonatomic, assign, readonly) BOOL didPrepared;
  28. @property (nonatomic, assign, readonly) BOOL didFinished;
  29. @property (nonatomic, assign, readonly) long long readOffset;
  30. - (void)prepare;
  31. - (void)close;
  32. - (NSData *)readDataOfLength:(NSUInteger)length;
  33. @end