ReadWriteStream

class ReadWriteStream : public IDataSourceStream

Base class for read/write stream.

Subclassed by CircularBuffer, EndlessMemoryStream, HardwareSerial, IFS::FileStream, LimitedMemoryStream, MemoryDataStream, Ota::UpgradeOutputStream, OtaUpgrade::BasicStream, Storage::PartitionStream, StreamWrapper, USB::CDC::UsbSerial

Public Functions

inline virtual size_t write(uint8_t charToWrite) override

From Stream class: We don’t write using this stream.

Parameters:

charToWrite

virtual size_t write(const uint8_t *buffer, size_t size) override = 0

Write chars to stream.

Note

Although this is defined in the Print class, ReadWriteStream uses this as the core output method so descendants are required to implement it

Parameters:
  • buffer – Pointer to buffer to write to the stream

  • size – Quantity of chars to write

Return values:

size_t – Quantity of chars written to stream

virtual size_t copyFrom(IDataSourceStream *source, size_t size = SIZE_MAX)

Copy data from a source stream.

Parameters:
  • source – Stream to read data from

  • size – Quantity of chars to write, determines size of intermediate buffer to use

Return values:

size_t – Quantity of chars actually written, may be less than requested

size_t write(uint8_t c) = 0

Writes a single character to output stream.

Parameters:

c – Character to write to output stream

Return values:

size_t – Quantity of characters written to output stream

inline size_t write(const char *str)

Writes a c-string to output stream.

Parameters:

str – Pointer to c-string

Return values:

size_t – Quantity of characters written to stream

size_t write(const uint8_t *buffer, size_t size)

Writes characters from a buffer to output stream.

Parameters:
  • buffer – Pointer to character buffer

  • size – Quantity of characters to write

Return values:

size_t – Quantity of characters written to stream

inline size_t write(const char *buffer, size_t size)

Writes characters from a buffer to output stream.

Parameters:
  • buffer – Pointer to character buffer

  • size – Quantity of characters to write

Return values:

size_t – Quantity of characters written to stream