8LinkInputStream::LinkInputStream(LinkInputStream&& other) {
9 channel_ = other.channel_;
10 my_stream_id_ = other.my_stream_id_;
11 status_ = other.status_;
12 other.channel_ =
nullptr;
13 other.my_stream_id_ = 0;
14 other.status_ = roo_io::kClosed;
17LinkInputStream& LinkInputStream::operator=(LinkInputStream&& other) {
19 channel_ = other.channel_;
20 my_stream_id_ = other.my_stream_id_;
21 status_ = other.status_;
22 other.channel_ =
nullptr;
23 other.my_stream_id_ = 0;
24 other.status_ = roo_io::kClosed;
29void LinkInputStream::close() {
30 if (status_ != roo_io::kOk && status_ != roo_io::kEndOfStream)
return;
31 channel_->closeInput(my_stream_id_, status_);
32 if (status_ != roo_io::kOk && status_ != roo_io::kEndOfStream)
return;
33 status_ = roo_io::kClosed;
36size_t LinkInputStream::read(roo::byte* buf,
size_t count) {
37 if (count == 0 || status_ != roo_io::kOk)
return 0;
38 return channel_->read(buf, count, my_stream_id_, status_);
57size_t LinkInputStream::tryRead(roo::byte* buf,
size_t count) {
58 if (count == 0 || status_ != roo_io::kOk)
return 0;
59 return channel_->tryRead(buf, count, my_stream_id_, status_);
62size_t LinkInputStream::available() {
63 if (status_ != roo_io::kOk)
return 0;
64 return channel_->availableForRead(my_stream_id_, status_);
67int LinkInputStream::read() {
68 if (status_ != roo_io::kOk)
return 0;
70 size_t count = channel_->tryRead(&result, 1, my_stream_id_, status_);
71 if (count > 0)
return (
int)result;
75int LinkInputStream::peek() {
76 if (status_ != roo_io::kOk)
return -1;
77 int result = channel_->peek(my_stream_id_, status_);
78 if (result >= 0)
return result;