diff options
Diffstat (limited to 'src/voltronic/shared_buf.cc')
-rw-r--r-- | src/voltronic/shared_buf.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/voltronic/shared_buf.cc b/src/voltronic/shared_buf.cc new file mode 100644 index 0000000..143a6f0 --- /dev/null +++ b/src/voltronic/shared_buf.cc @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-3-Clause + +#include "device.h" + +namespace voltronic { + +void SharedIOBuffer::resetWith(const u8* inbuf, + size_t inbufSize, + u8* outbuf, + size_t outbufSize) { + // set input + inputBuffer = inbuf; + inputBufferSize = inbufSize; + + outputBuffer = outbuf; + outputBufferSize = outbufSize; + + // clean output + errorType = ErrorType::None; + errorMessage.erase(); + dataSize = 0; + + // mark as ready + state = SharedIOBufferState::Ready; +} + +void SharedIOBuffer::setResult(ErrorType type, std::string message) { + errorType = type; + errorMessage = std::move(message); + state = SharedIOBufferState::Done; +} + +void SharedIOBuffer::setResult(size_t _dataSize) { + dataSize = _dataSize; + state = SharedIOBufferState::Done; +} + +}
\ No newline at end of file |