PipeBuffer()
PipeBuffer()
An IOBuffer that allows reading and performs writes by appending. Seeking and truncating are not supported. See IOBuffer for the available constructors.
Examples
-
Create a PipeBuffer without specifying a maximum size:
julia> data = [0x41, 0x42, 0x43, 0x44]; julia> buf = PipeBuffer(data) PipeBuffer([0x41, 0x42, 0x43, 0x44])This example creates a
PipeBufferobjectbufusing thedatavector. -
Create a PipeBuffer with a maximum size:
julia> data = [0x41, 0x42, 0x43, 0x44]; julia> buf = PipeBuffer(data, 10) PipeBuffer([0x41, 0x42, 0x43, 0x44], 10)Here, a
PipeBufferobjectbufis created with thedatavector and a maximum size of 10. - Use the PipeBuffer for operations:
julia> data = [0x41, 0x42, 0x43, 0x44]; julia> buf = PipeBuffer(data); julia> write(buf, 0x45) 5 julia> read(buf) 0x41In this example, the
PipeBufferobjectbufis used to write and read data.
Common mistake example:
julia> data = [0x41, 0x42, 0x43, 0x44];
julia> buf = PipeBuffer(data, 3)
ERROR: ArgumentError: The PipeBuffer cannot exceed the specified maxsize.
In this case, the specified maxsize is smaller than the size of the data vector. Ensure that the maxsize provided is greater than or equal to the size of the data vector to avoid this error.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.