mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Support payload offsets
Support sending a file or stream payload from a non-zero offset. This allows the clients to resume a transfer. Upper layers should use this feature only when both sides support it. PiperOrigin-RevId: 385137570
This commit is contained in:
committed by
Copybara-Service
parent
a8fe61d846
commit
ed511f962d
@@ -32,6 +32,12 @@ class BaseInputStream : public InputStream {
|
||||
|
||||
ExceptionOr<ByteArray> Read(std::int64_t size) override;
|
||||
|
||||
ExceptionOr<size_t> Skip(size_t offset) override {
|
||||
size_t real_offset = std::min(offset, buffer_.size() - position_);
|
||||
position_ += real_offset;
|
||||
return ExceptionOr<size_t>(real_offset);
|
||||
}
|
||||
|
||||
Exception Close() override {
|
||||
// Do nothing.
|
||||
return {Exception::kSuccess};
|
||||
|
||||
Reference in New Issue
Block a user