Base class for transfer handlers.
Transfer handlers connect a transfer resource ID to a data stream, wrapped with initialization and cleanup procedures. Handlers use a pw::stream::Reader or pw::stream::Writer to perform reads and writes, and provide optional Prepare and Finalize methods invoked from the transfer thread.
Public Member Functions | |
| constexpr uint32_t | id () const |
| virtual Status | PrepareRead ()=0 |
| virtual Status | PrepareRead (uint32_t offset) |
| virtual void | FinalizeRead (Status status) |
| virtual Status | PrepareWrite ()=0 |
| virtual Status | PrepareWrite (uint32_t offset) |
| virtual Status | FinalizeWrite (Status status) |
| virtual size_t | ResourceSize () const |
| virtual Status | GetStatus (uint64_t &readable_offset, uint64_t &writeable_offset, uint64_t &read_checksum, uint64_t &write_checksum) |
Protected Member Functions | |
| constexpr | Handler (uint32_t resource_id, stream::Reader *reader) |
| constexpr | Handler (uint32_t resource_id, stream::Writer *writer) |
| void | set_reader (stream::Reader &reader) |
| void | set_writer (stream::Writer &writer) |
Protected Member Functions inherited from pw::IntrusiveForwardList< T >::Item | |
| constexpr | Item ()=default |
Friends | |
| class | internal::Context |
|
inlineconstexprprotected |
Constructs a Handler with an optional initial pw::stream::Reader.
| [in] | resource_id | Unique ID of the transferable resource. |
| [in] | reader | Optional reader stream to associate with this handler. |
|
inlineconstexprprotected |
Constructs a Handler with an optional initial pw::stream::Writer.
| [in] | resource_id | Unique ID of the transferable resource. |
| [in] | writer | Optional writer stream to associate with this handler. |
|
inlinevirtual |
Called on the transfer thread at the end of a read transfer.
| [in] | status | Overall status indicating whether the data transfer succeeded. |
Reimplemented in pw::transfer::AtomicFileTransferHandler.
Called on the transfer thread at the end of a write transfer.
Returning an error signals that the transfer failed, even if data transfer had succeeded up to this point.
| [in] | status | Status indicating whether the data transfer succeeded up to finalization. |
Reimplemented in pw::transfer::AtomicFileTransferHandler.
|
inlinevirtual |
Queries application-defined status metadata for this resource in response to a Transfer.GetResourceStatus RPC.
| [out] | readable_offset | Readable byte offset of the resource. |
| [out] | writeable_offset | Writeable byte offset of the resource. |
| [out] | read_checksum | Checksum of readable data. |
| [out] | write_checksum | Checksum of written data. |
|
inlineconstexpr |
Returns the unique identifier for the resource managed by this handler.
|
pure virtual |
Called on the transfer thread at the beginning of a read transfer. The pw::stream::Reader must be set and ready to read after a successful PrepareRead() call. Returning a non-OK status aborts the read.
Implemented in pw::transfer::WriteOnlyHandler, pw::transfer::AtomicFileTransferHandler, pw::transfer::ReadOnlyHandler, and pw::transfer::ReadWriteHandler.
|
inlinevirtual |
Called on the transfer thread at the beginning of a non-zero-offset read transfer.
Implementations should verify that offset is a valid read point for the resource and position the pw::stream::Reader to read from offset before returning \ref pw::OkStatus() "OK". Returning a non-OK status aborts the read.
| [in] | offset | Starting byte offset for the read transfer. |
offset and ready for the transfer.offset is past the end of the stream.
|
pure virtual |
Called on the transfer thread at the beginning of a write transfer. The pw::stream::Writer must be set and ready to write after a successful PrepareWrite() call. Returning a non-OK status aborts the write.
Implemented in pw::transfer::ReadOnlyHandler, pw::transfer::AtomicFileTransferHandler, pw::transfer::WriteOnlyHandler, and pw::transfer::ReadWriteHandler.
|
inlinevirtual |
Called on the transfer thread at the beginning of a non-zero-offset write transfer.
Implementations should verify that offset is a valid write point for the resource and prepare the pw::stream::Writer to write at offset before returning \ref pw::OkStatus() "OK". Returning a non-OK status aborts the write.
| [in] | offset | Starting byte offset for the write transfer. |
offset and ready for the transfer.offset is past the end of the resource.
|
inlinevirtual |
Returns the total size of the transfer resource in bytes, if known.
std::numeric_limits<size_t>::max() if unknown.
|
inlineprotected |
Sets the pw::stream::Reader used by this handler.
| [in] | reader | Stream from which transfer data will be read. |
|
inlineprotected |
Sets the pw::stream::Writer used by this handler.
| [in] | writer | Stream to which transfer data will be written. |